[Python-3000] PEP to change how the main module is delineated
Guido van Rossum
guido at python.org
Tue Apr 24 00:56:49 CEST 2007
On 4/23/07, Adam Olsen <rhamph at gmail.com> wrote:
> On 4/23/07, Guido van Rossum <guido at python.org> wrote:
> > I'm -1 on this and on any other proposed twiddlings of the __main__
> > machinery. The only use case seems to be running scripts that happen
> > to be living inside a module's directory, which I've always seen as an
> > antipattern. To make me change my mind you'd have to convince me that
> > it isn't.
>
> So ./python Lib/test/regrtest.py and ./python
> Lib/test/test_something.py are both wrong?
I'll happily admit they are bad examples, though as long as they work
I don't care (and since they do work, I don't see them as motivating
the PEP :-).
This occasionally causes problems when someone adds a new test module
that imports stuff using implicit relative imports. Fortunately those
will be gone in py3k.
> I note there's 26 files
> marked executable and 50 with #!/usr/bin/env python, so there's quite
> a bit of prior art in the "old way".
Where are these files? If they are directly in Lib, that's not a
problem. The PEP only addresses what happens if these are in a
subpackage (like test).
> Besides correcting the stdlib, adding a warning when running a script
> from a dir with __init__.py would help change the momentum.
Patch anyone? We could move regrtest out of the test package into Lib.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list