[Python-Dev] Choosing a best practice solution for Python/extension modules

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Feb 21 06:14:39 CET 2009


Daniel Stutzbach wrote:

> No, I'm afraid Brett is quite right.  Globals are looked up when the 
> function is executed, true, but they are looked up within the module 
> that defined the function.

I was thinking you could fix that by going over the
imported functions and stuffing the current globals
into their func_globals, but unfortunately it's
read-only. :-(

 >>> f.func_globals = g
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: readonly attribute

Is there a reason it couldn't be made writeable?

-- 
Greg


More information about the Python-Dev mailing list