Accessing variables in __main__ from modules....
Carel Fellinger
cfelling at iae.nl
Thu Mar 29 18:02:21 EST 2001
nanotech at europa.com wrote:
> DEBUG would be searched for at the module scope. But I want it to
> look for DEBUG back in __main__, like:
The most straightforwarth way to achieve this would be to import Debug
from main, or better to have a seperate options module and import from
there. like:
module options:
DEBUG = 0
main module:
import options
...
options.DEBUG = 1
other module:
from options import DEBUG
if DEBUG:
print "-I-: Reading '%s'....has %s lines...."%len(filename,lines)
--
groetjes, carel
More information about the Python-list
mailing list