Title: namespace question

Hi all,

I'm confused by namespaces in python, specifically using the global keyword.  I'm able to access and modify a global variable from a function if the function is defined in the same module but not if the function is defined in a different module:

//File t2.py
def sn():
    global test_var
    test_var = 2

//File t1.py
test_var = 1
print test_var
from t2 import sn
sn()
print test_var
def so():
    global test_var
    test_var = 3
so()
print test_var


The output from running t1 is:
1
1
3

Can anyone tell me how I can modify the test_var variable form another module?

Pete

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to