usenet at soraia.com
Mon Jul 21 19:13:00 CEST 2003
> I have one "master" program which calls a small program. In this small
> program I want to work with a value from the "master" program. But I
> always get this error: NameError: global name 'T' is not defined
> How can I define a global variable?
> Thanks for your help.
> Regards, Tom
You can't (well, there is a way, but you probably don't want to be
messing with that).
By "program" I assume you mean "module". You can do something like:
T = 'Some value'
However, if master.py is also importing small.py, you'll get a circular
reference, which may cause hard to track bugs, in which case it's best
to have a third module for common (global) variables (and functions, if
you'd like), and have both master.py and small.py import that.
More information about the Python-list