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 8766551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:34:59+00:00 2026-06-13T16:34:59+00:00

Let’s say I’ve a file a.py and a has a variable var . In

  • 0

Let’s say I’ve a file a.py and a has a variable var.

In file b.py, I imported, a.py and set a.var = "hello".

Then I imported a.py in c.py and tried to access a.var but I get None.

How to reflect the change in data? It is obvious that two different instances are getting called, but how do I change it?

Edit:

What I am trying to do here is create a config file which constitutes of this:

CONFIG = {
    'client_id': 'XX',
    'client_secret': 'XX',
    'redirect_uri': 'XX'
    }

auth_token = ""

auth_url = ""

access_point = ""

Now, let’s say I use config.py in the script a.py and set config.access_point = “web”

So, if I import config.py in another file, I want the change to reflect and not return “”.

Edit:

Text file seems like an easy way out. I can also use ConfigParser module. But isn’t it a bit too much if reading form a file needs to be done in every server request?

  • 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-13T16:35:00+00:00Added an answer on June 13, 2026 at 4:35 pm

    As a preliminary, a second import statement, even from another module, does not re-execute code in the source file for the imported module if it has been loaded previously. Instead, importing an already existing module just gives you access to the namespace of that module.

    Thus, if you dynamically change variables in your module a, even from code in another module, other modules should in fact see the changed variables.

    Consider this test example:

    testa.py:

    print "Importing module a"
    var = ""
    

    testb.py:

    import testa
    testa.var = "test"
    

    testc.py:

    import testa
    print testa.var
    

    Now in the python interpreter (or the main script, if you prefer):

    >>> import testb
    Importing module a
    >>> import testc
    test
    >>>
    

    So you see that the change in var made when importing b is actually seen in c.

    I would suspect that your problem lies in whether and in what order your code is actually executed.

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I can call a method like this: core::get() . What is the
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say there is a graph and some set of functions like: create-node ::
Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class, with certain properties, and that you tried your

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.