Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:50:53+00:00 2026-06-17T05:50:53+00:00

I understand how to actually link python files, however, i don’t understand how to

  • 0

I understand how to actually link python files, however, i don’t understand how to get variable’s from these linked files. I’ve tried to grab them and I keep getting NameError.

How do I go about doing this? The reason i want to link files is to simply neaten up my script and not make it 10000000000 lines long. Also, in the imported python script, do i have to import everything again? Another question, do i use the self function when using another scripts functions?

ie;

Main Script:

import sys, os
import importedpyfile

Imported Py File

import sys, os
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:50:55+00:00Added an answer on June 17, 2026 at 5:50 am

    I understand how to actually link python files, however, i don’t
    understand how to get variable’s from these linked files. I’ve tried
    to grab them and I keep getting NameError.

    How are you doing that? Post more code. For instance, the following works:

    file1.py

    #!/usr/bin/env python
    
    from file2 import file2_func, file2_variable
    
    file2_func()
    print file2_variable
    

    file2.py:

    #!/usr/bin/env python
    
    file2_variable = "I'm a variable!"
    
    def file2_func():
        print "Hello World!"
    

    Also, in the imported python script, do i have to import everything
    again?

    Nope, modules should be imported when the python interpreter reads that file.

    Another question, do i use the self function when using another
    scripts functions?

    Nope, that’s usually to access class members. See python self explained.

    There is also more than one way to import files. See the other answer for some explanations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am actually new with these XML stuff. I do understand things about the
As I understand it MEM_RESERVE is actually 'free' memory, ie available to be used
Like I understand, @synthesize actually is generating the Getters and Setters. But what's @property
I understand that 2 options are available: Non-persistent Persistent But what does this actually
I understand the basics of Rx. Where I'm struggling is how you would actually
I am trying to understand simple snaplet construction. Also, when do I actually need
I understand, from MSDN, that ClassInitialize is to mark a method that will do
A simple link would be nice for me to understand how to install my
Normal page looks like this: http://hell.orts.ru:8004/snapboard/threads/id/3/ However, if …#fragment_id is used in the link,
I want to pass callback from my python code to c++ I want my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.