py older2.py
py newer3.py
Working from cmd window, you can also left out the py and launch it as if the script were executable:
older2.py
newer3.py
You can even omit the extension when launching from the cmd console:
older2
newer3
or--if you prefer--it allows you to launch the Python application using mouse double-click on the script icon. The version of Python that is to be used for interpreting the script can now be captured inside the script. And this is a good thing.
When MS Windows is finished, it will be the best documented Unix in the World.Unix uses very clear, simple, and clever abstractions from the very beginning. A file is a stream of bytes. There is a structure bound to the stream of bytes that represents the stream of bytes as a pure file abstraction -- think about the anonymous structure (i.e. unnamed, identified only by a number). Having access to that structure, you have access to the file bytes. The structure captures also attributes of the file. One of the attributes is the flag that says "this file is executable". A directory is just another file (with the directory flag) that bounds the file id's (numbers) with the file names. Nothing more, nothing less.
(A prophet unknown to me -- some say that Joker is her name.)
Say where they are, and cause that I may know them;
For great desire constraineth me to learn
If Heaven doth sweeten them, or Hell envenom.
And he: They are among the blacker souls;
A different sin downweighs them to the bottom;
If thou so far descendest, thou canst see them.
(Dante Alighieri, Divine Comedy)
c:\Python23
c:\Python25
c:\Python26
c:\Python27
c:\Python32
Say, c:\Python27 and c:\Python32 is in your PATH. Some of your scripts need Python 2.x, some newer scripts need Python 3.x. For working with command line, you have renamed c:\Python32\python.exe to c:\Python32\python3.exe. Then you can launch older scripts as
python older.py
and newer scripts as
python3 newer.py
And because you start to use more and more of the newer scripts (for Python 3), you have later renamed c:\Python32\python3.exe to c:\Python32\py.exe. And the life is easier now.
py newer.py
c:\Python33\python.exe
immediately renamed to the c:\Python33\py.exe. You have also changed the PATH to prefer the newer Python 3.3...
c:\myproject>py newer.py
File "newer.py", line 3
SyntaxError: Non-ASCII character '\xc5' in file newer.py on line 4,
but no encoding declared; see http://www.python.org/peps/pep-0263.html
for details
"What is that?"
c:\Python33\py.exe newer.py
Succeeded.
!@#$%^&* Windows *&^%$#@! (censored)
C:\Windows\py.exe
... and the date of the file is new. It is the time to read the doc: What’s New In Python 3.3...
PEP 397: Python Launcher for WindowsSigh...
The Python 3.3 Windows installer now includes a py launcher application that can be used to launch Python applications in a version independent fashion.
...
3.4. Python Launcher for Windows
New in version 3.3.
The Python launcher for Windows is a utility which aids in the location and execution of different Python versions. It allows scripts (or the command-line) to indicate a preference for a specific Python version, and will locate and execute that version.
...
PEP 397 -- Python launcher for Windows
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Commented:
ericpete
Page Editor