globals accros modules

alf ask at me
Wed Jan 10 23:11:28 EST 2007


Hi,
executing main.py reulsts in following:


[andy at localhost andy]$ python main.py
Traceback (most recent call last):
   File "main.py", line 4, in ?
     amodule.f()
   File "/raid/home/andy/amodule.py", line 3, in f
     print a
NameError: global name 'a' is not defined

How can I have global globals without cyclical import?

A.


--------------------
amodule.py:
def f():
     global a
     print a
--------------------
main.py:
import amodule
a=1
amodule.f()





More information about the Python-list mailing list