I "think" global is broken
Larry Bates
lbates at swamisoft.com
Wed Nov 6 16:24:21 EST 2002
The following code works as expected.
class test:
global _trace
def __init__(self):
if _trace: print "entering test.__init__"
return
global _trace
_trace=1
x=test()
Now if I move the class into a separate module called test.py
and change the main program it no longer works
from test import *
global _trace, _debug
_trace=1
x=test()
I get undefined global error
I just don't believe that this is the way it should work.
I understand that in this simple example I could
do an import test and (according to other posts
I've read it should work). But in a real world
example the external module has 8 classes in it
(and growing). It just doesn't seem right that I
would need to split it into 8 different modules.
Am I missing something?
Thanks in advance for any assistance.
Regards,
Larry Bates
lbates at swamisoft.com
More information about the Python-list
mailing list