the global keyword:
Rick Johnson
rantingrickjohnson at gmail.com
Tue Jun 21 13:04:50 EDT 2016
On Sunday, June 12, 2016 at 2:08:01 PM UTC-5, BartC wrote:
> Anyway, it shows Python doesn't have true cross-module globals.
BS! You can inject symbols into sys.modules and achieve a
true global.
## BEGIN: INTERACTIVE SESSION ##
py> import sys
py> def foo():
... print 'My name is foo'
py> sys.modules['__builtin__'].__dict__['foo_func'] = foo
py> foo_func()
My name is foo
## END: INTERACTIVE SESSION ##
More information about the Python-list
mailing list