Turn of globals in a function?
Greg Ewing
greg at cosc.canterbury.ac.nz
Wed Mar 30 23:28:15 EST 2005
Oren Tirosh wrote:
> def noglobals(f):
> . import new
> . return new.function(
> . f.func_code,
> . {'__builtins__':__builtins__},
> . f.func_name,
> . f.func_defaults,
> . f.func_closure
> . )
Be aware that this will render the function incapable
of seeing *any* globals at all, including other
functions and classes defined in the same module --
which you may find rather inconvenient!
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list