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

Steven Bethard steven.bethard at gmail.com
Mon Apr 23 15:53:44 CEST 2007


On 4/23/07, Barry Warsaw <barry at python.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Apr 23, 2007, at 9:21 AM, Christian Heimes wrote:
>
> > -1 on __module__
> >
> > I understand PEP 3020 correctly then sys.main will contain the dotted
> > name of the module as *string*.
> >
> > Also __module__ is already used in objects like classes.
>
> I'm not sure whether a general mechanism is necessary or not, but
> I've always wished I could just do something like "import __me__" to
> get the current module.

Well, you can always do::

    __import__(__name__)

That's not much more verbose.

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list