[Python-3000] PEP 30xx: Access to Module/Class/Function Currently Being Defined (this) (original) (raw)

Jim Jewett jimjjewett at gmail.com
Mon Apr 23 18:52:59 CEST 2007


On 4/23/07, Christian Heimes <lists at cheimes.de> wrote:

Steven Bethard wrote: > Of course, to make it work with packages, you have to write something like::

> mod = import(name) > for submodname in name.split('.')[1:]: > mod = getattr(mod, submodname)

> I guess that's not so simple after all. > > STeVe

Do you want to do something like:

import sys mod = sys.modules[name] mod = sys.modules[self.class.module]

Sure. But I also want it to work, even if module.name has been changed, or module has been removed from sys.modules (perhaps for security reasons), or some other module is already using that name.

That said, I won't be shocked if Guido eventually decides to support only one or two of the magic words, just as he initially limited decorators to functions.

-jJ



More information about the Python-3000 mailing list