[Python-ideas] PEP for executing a module in a package containing relative imports
steven.bethard at gmail.com
Sun Apr 22 20:32:03 CEST 2007
On 4/22/07, Christian Heimes <lists at cheimes.de> wrote:
> Steven Bethard wrote:
> > 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'm proposing the following changes:
> * sys.main is added which contains the dotted name of the main script.
> This allows code like:
> if __name__ == sys.main:
Note that this really requires the code::
if __name__ == sys.main:
The import statement matters to me because 77% of my modules that use
the __main__ idiom *don't* import sys. Hence, for those modules, this
new idiom introduces more boilerplate.
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