[Python-ideas] Rename python.exe to python3.exe on Windows

Mathias Panzenböck grosser.meister.morti at gmx.net
Mon May 9 18:43:13 CEST 2011


I would say in every Python installation there should be a binary with the version number attached. 
I think in most (all?) Linux distributions this is already the case. E.g. there is python2.7 and 
python3.2. There is also python2, that links to some python2.x, and python3 that links to some 
python3.x, and then there is python, that links to any of the above.

Under Linux/Mac OS X we already add a line like this to our scripts:
#!/usr/bin/env python

Or better:
#!/usr/bin/env python3

I say it should be documented that the first is deprecated and the latter form shall be used. Using 
"#!/usr/bin/env python" should mean "this script is written so that it can be run in *any* python 
version", which is pretty unrealistic. "#!/usr/bin/env python3" should mean "this script is written 
so that it can be run in any python 3.x version" and so on.

Of course there are scripts that do not use this right. They should be considered as broken and be 
fixed. (Maybe print deprecation warnings if possible?)

Now on Windows there is no #! mechanism. I think it would be worthwhile to fix this and implement a 
python-dispatcher for Windows. This would then parse the #!-line, drop the "/usr/bin/env" part (if 
it exists) and lookup the right Python binary form a registry variable. I don't know if there are 
any registry variables set in a Windows Python installation that let you find the binary of a 
certain version, but I think it would be a good thing.

This way correct scripts would just work under Unix (Linux, Mac, BSD) and Windows. And under Windows 
you would not have any problems with file type associations. *.py and *.pyw files just have to be 
associated with the dispatcher. It should not matter if the dispatcher is from a Python 2.x or 
Python 3.x installation.

	-panzi

On 05/09/2011 12:39 PM, Stephen J. Turnbull wrote:
> Steven D'Aprano writes:
>
>   >  I wish I could find the quote somebody made about Arch being the distro
>   >  that makes Gentoo seem cautious and conservative... something about Arch
>   >  moving forward so the Gentoo folks know which mistakes not to make?
>
> The only thing history teaches us is that nobody learns from
> others' history:
>
> $ python
> Python 3.1.3 (r313:86834, Feb 22 2011, 18:52:21)
> [GCC 4.3.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>>
> $
>
> There are a couple of ebuilds that break because of this.



More information about the Python-ideas mailing list