Executable Python programs on Windows

Starting with Python 3.3, Python on Windows also supports the use of the shebang to make Python scripts directly executable with the correct version of the Python interpreter, even to the extent that shebangs that look like they should only work on Unix-like systems will work as expected on Windows. This works because Windows Python distributions now use a program called PyLauncher. PyLauncher, the executable for which is called simply py.exe, will parse the shebang and locate the appropriate version of Python.

For example, on Windows at the cmd prompt, this command will be sufficient to run your script with Python 3 (even if you also have Python 2 installed):

> words.py http://sixty-north.com/c/t.txt

In Powershell the equivalent is:

PS> .words.py http://sixty-north.com/c/t.txt

You can read more about PyLauncher in PEP 397.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset