[Python-ideas] PEP for executing a module in a package containing relative imports (original) (raw)

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 thismodule 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.

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