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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to