[Python-Dev] __module__ of newly-created extension classes

David Abrahams David Abrahams" <david.abrahams@rcn.com
Thu, 30 May 2002 18:00:37 -0400


From: "Guido van Rossum" <guido@python.org>


> > Now I'm wondering if there isn't a better way for Python to get
> > ahold of the current module's __name__ in this case, if you don't
> > want to change what PyEval_GetGlobals() does.
>
> If you can rigorously define "current module" I can propose an API.

A rigorous definition is easy; I can't promise it would always meet
everyone's expectations:

The "current module" is given by the current formula (PyEval_GetGlobals(),
etc.) except when loading an extension module, in which case the current
module is the one most recently created.

I'm not sure, but this might be simplifiable to:

the "current module" is the one most recently created.


-Dave