| Store | Cart

Turn of globals in a function?

From: Greg Ewing <g...@cosc.canterbury.ac.nz>
Thu, 31 Mar 2005 16:28:15 +1200
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

Recent Messages in this Thread
Ron_Adam Mar 26, 2005 08:01 pm
Michael Spencer Mar 26, 2005 08:18 pm
Bengt Richter Mar 26, 2005 09:02 pm
Ron_Adam Mar 27, 2005 02:49 am
Oren Tirosh Mar 27, 2005 06:51 am
Ron_Adam Mar 27, 2005 04:45 pm
Greg Ewing Mar 31, 2005 04:28 am
Ron_Adam Mar 31, 2005 05:31 pm
Ron_Adam Mar 27, 2005 02:13 am
Messages in this thread