Weird Python behavior Jonathan S. Shapiro (shap@eros-os.org)
Wed, 26 Apr 2000 15:04:30 -0400

I have a stupid python question. I'm hoping somebody can answer it. I'm not clear
on whether it's a failure of my understanding or a bug in Python or both. The problem involves failed visibility of updates to global variables. I have narrowed it down to a small example. I am running python 1.5.2. I'm getting desperate, because I'm stuck until this is solved.

I have two python files

main.py:
===

import broken;

somevar = None;

if __name__ == "__main__":

global somevar

somevar = 1;
broken.showme();
===

broken.py:
===

import main

def showme():

print main.somevar
===

My question: Showme() prints "None". Why doesn't showme() print the value "1"?

What's going on here?