PyWart fixed mostly, was: Re: Python Gotcha's?

Bryan bryanjugglercryptographer at yahoo.com
Tue Jan 22 03:57:50 EST 2013


On Apr 14 2012, 2:47 pm I wrote:
> Miki Tebeka wrote:
> > If you have an interesting/common "Gotcha" (warts/dark corners ...) please share.
>
> Python 3(K) likes to use the same '.py' file extension as its
> incompatible predecessors, and in some/many/most *nix implementations,
> it likes to install in the same place. Python 3 is an improvement upon
> Python 2, but Python went from, "sure... Python just works," to,
> "well... that depends... which Python?"

My "gotcha" is addressed by PEP 394, "The 'python' Command on Unix-
Like Systems", and PEP 397, "A Python launcher for Windows". They
alleviate much of that pain and suffering of running both Python 2.x
and 3.x.

On *nix systems, if a Python 2 interpreter is available it should be
runnable as "python2". If Python 3 is available, it should runnable as
"python3". The modern Python shebang line is "#!/usr/bin/env python3".
[PEP 394]

On Microsoft Windows, the latest and greatest Python installation,
3.3, no longer usurps the ".py" extension for its own version-specific
interpreter. It associates ".py" with a multi-version launcher, called
"py", that makes a reasonable attempt to do the right thing py-version-
wise. The modern shebang line will help even on MS-Windows. [PEP 397]

There's room for improvement. The launcher invocation, "py", should
work on Unix. And everywhere it runs it should respect shebang lines
that name itself. The modern shebang line ought to be "#!/usr/bin/env
py -3" (but it's not yet so don't use it).

The other big idea in supporting multiple Pythons is virtual
environments. Python 3.3 has PEP 405, virtual environments in the
core. Unfortunately the aforementioned PEP 397 windows launcher, also
in Python 3.3, ignores an active virtual environment. Be warned.


-Bryan



More information about the Python-list mailing list