Am Wed, 12 Sep 2007 11:54:51 +1000 schrieb bambam: > def gim(): > exec "global gamel" > exec "import gamel" > > Unfortunately, does not have the desired effect. > Steve.
Both statements have to be part of a single exec:
def gim():
modulename = "gamel" # determined at runtime
exec "global %s; import %s" % (modulename, modulename)
It may work, but it is still a bad idea to create global variables with a
name not known until runtime.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
