[Python-ideas] PEP for executing a module in a package containing relative imports

Steven Bethard steven.bethard at gmail.com
Sun Apr 22 19:42:38 CEST 2007

On 4/22/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> # Equivalent to today
> if __name__ == sys.modules["__main__"].__name__:
> # Better than today
> if __name__ is sys.modules["__main__"].__name__:
> # What I would like (pending PEP I hope to write tonight)
> if __this_module__ is sys.modules["__main__"]:

Is it just me, or are the proposals starting to look more and more like::

    public static void main(String args[])

I think this PEP now needs to explicitly state that keeping the "am I
the main module?" idiom as simple as possible is *not* a goal. Because
everything I've seen (except for the original proposals in the PEP)
are substantially more complicated than the current::

    if __name__ == '__main__':

I guess I don't understand why we wouldn't be willing to put up with a
new module attribute or builtin to minimize the boilerplate in pretty
much every Python application out there.

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-ideas mailing list