[Python-ideas] Migration of /usr/bin/python to python3

Neil Schemenauer nas-python at arctrix.com
Wed Mar 11 20:43:25 CET 2015


This has been brought up elsewhere, I think this is a better forum
to discuss it.  Changing /usr/bin/python directly to python3.x is
bad idea, in my option.  It's going to cause users trouble and the
benefit to Python 3.x users is not worth it.  Instead, let's try to
find a smooth migration path.

One idea is to install Python 3 as /usr/bin/python but have it
always execute scripts with Python 2 unless they are explicitly
marked as Python 3 compatible.  

The interpreter could parse the first line of the script to look for
options.  Traditionally the OS only passes the first option to the
interpreter so anything after that could be used to pass 3.x
specific options.

For example, a script starting with 

    #!/usr/bin/python -x -3

could signify that the script is compatible with a Python 3
interpreter.

An alternative idea is to allow something like the 'encoding'
declaration.  It wouldn't have to be in the first line and would
allow more flexibility.  Many years in the future when all scripts
are marked as Python 3 compatible, Python 2 can be removed from the
system and /usr/bin/python will start Python 3 by default.

I suppose running '/usr/bin/python' interactively could start Python
3 by default.  However, I strongly feel that existing Python 2
scripts should not get broken in a flag day like way.


  Neil


More information about the Python-ideas mailing list