Question about using from/import from with a class
John Taylor
john_taylor_1973 at yahoo.com
Tue Jul 27 13:32:41 EDT 2004
I have a class that has this code in it:
def __init__(self,Site):
self.Site = Site
import_cmd = "from regexpr_%d import *" % ( int(self.Site.id) )
exec( import_cmd )
print AGENT # fails, NameError: global name 'AGENT' is not defined
The regexpr_1.py file, for example, has the line:
AGENT="Mozilla"
After the exec() command is ran, how to I access varaibles defined in
the regexpr_%d file?
Thanks,
John
More information about the Python-list
mailing list