[Python-3000] [Python-ideas] Namespaces are one honking great idea -- let's do more of those!

Christian Heimes lists at cheimes.de
Mon Feb 4 16:21:46 CET 2008


Mike Meyer wrote:
> -2 on using the shebang line for this. The 2.X version-specific
> binaries are python2.X, so to use that, you'd have to make the shebang
> line invoke python2.X. Right now, if you upgrade an installation from
> 2.X to 2.X+1, you can expect most of the scripts to work assuming you
> take do care to install the same module set. Requiring explicit minor
> versions breaks that.

I'm on Mike's side here. There is no need to fix the Unix (and Mac OS X)
side of the problem because it was never broken in the first place.

The only problematic environment is (as usual) Windows. Windows has no
shebang and python.exe is most likely not in PATH. One has to go through
the registry to find Python 2.x and its executable.

For Windows the Python stdlib should get some means of starting a script
with a well defined Python version without relying on the file
extension. One possible way is to assign the .py and .pyw extension with
a small wrapper program written in C which parses the #! shebang line,
gets the right python.exe from the registry and starts the script with it.

Another way is a new Python extension (maybe .pys for python start) for
ini file like startup files:

---
[Python]
version=2.5,2.6
module=myprogram.main
gui=True

[Env]
pythonpath=..
---

The file causes the startup program to search for 2.5 and 2.6 in the
registry. It sets the env var PYTHONPATH to .. (relative to the location
of the file) and starts the program with pythonw.exe -m "myprogram.main".

Christian



More information about the Python-3000 mailing list