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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:12:38+00:00 2026-05-27T07:12:38+00:00

OK I am doing some threading, and I guess when I started doing threading

  • 0

OK I am doing some threading, and I guess when I started doing threading I assumed you can’t return values like a definition (its the end of the day and my brain is about to die so maybe this is incorrect and I should start going back to get rid of global variables)

Anyway I have a test program to figure out why I can’t modularize my code

a file called config.py

a_variable=0

a file called test_for_sean.py

from config import *
def blah():
  global a_variable
  a_variable=14
  return 0

a file called main.py

from config import *
from test_for_sean import *
print a_variable #this prints correctly
blah()
print a_variable #this is still printing 0....

someone link me to something so I don’t kill myself

  • 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-05-27T07:12:39+00:00Added an answer on May 27, 2026 at 7:12 am

    Try these changes,

    config.py,

    a_variable = 0
    

    tfs.py (was test_for_sean),

    import config
    
    def blah():
        config.a_variable = 14
        return 0
    

    main.py,

    import tfs, config
    
    print config.a_variable
    tfs.blah()
    print config.a_variable
    

    We still import everything from config, but are ‘global’ variables stay in their own modules. This way we can have global variables but still let main.py define its own a_variable if it needs to.

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

Sidebar

Related Questions

I'm doing some multi-threading and use AutoResetEvents and ManualResetEvents do control my main -
I'm doing some code cleanup, and I came across a few instances of System.Threading.Thread.Sleep(2000);
Am new to python and making some headway with threading - am doing some
Doing some jquery animation. I have certain divs set up with an attribute of
After doing some work with Ruby, Rails, and RSpec last summer and I learned
While doing some JavaScript performance tests I came up with the following piece of
While doing some random experimentation with a factorial program in C, Python and Scheme.
While doing some refactoring I've found that I'm quite often using a pair or
I`m doing some web.config modifications with SPWebConfigModification class. When adding them to WebApplication and
After doing some research on the subject, I've been experimenting a lot with patterns

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.