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

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


On 4/23/07, Christian Heimes <lists at cheimes.de> wrote:
> >     Proposal:  Add a __module__ keyword which refers to the module
> >     currently being defined (executed).  (But see open issues.)

> -1 on __module__

> Also __module__ is already used in objects like classes.

Yes,  I worried that it might cause some confusion, but I also worry
that it might cause confusion *not* to reuse the name.

X.__module__ is the __module__ attribute of X
X.__class__ is the __class__ attribute of X

An (unqualified) __module__ would represent the current module.
An (unqualified) __class__ would represent the current class.

That said, the choice between reused short names (__module__) and
longer names (__this_module__, __current_module__, __thismodule__) is
indeed one of the open issues.  I'll count this as one vote against
the short forms.

-jJ


More information about the Python-3000 mailing list