On Tue, Aug 5, 2014 at 9:56 AM, Marc Tompkins <marc.tompk...@gmail.com> wrote:
> On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel <maximestei...@gmail.com> 
> wrote:
>> I think this is because on windows, *.py files are associated with py.exe
>> that choose the python version depending on the first line of your file.
>
> No.  *ix operating systems (Unix, Linux, OS X, etc.) inspect the first
> line of a file to determine how to handle it; Windows does NOT.

Have a look at PEP 397[1].  You are correct, *Windows* does not look
at the shebang line.  However, Maxime is also correct in that Python
3.3+ installs the Python Launcher for Windows (py.exe) and associates
the .py extension with it, and *py.exe* does shebang line handling,
spawning the interpreter requested by the shebang line as a
subprocess.

> Windows simply looks at the filename extension (.py, .pyw, etc.) and
> consults its internal registry of file type associations.  The way
> that you, as a user, can edit those associations has changed over the
> years; in Windows 7 and 8, it's Control Panel\All Control Panel
> Items\Default Programs\Set Associations.
>
> On the other hand, when you start up CMD.EXE and type "python" at the
> prompt, Windows uses a procedure that goes back to DOS 2 or so: the
> PATH environment variable.  This is similar to, but a little different
> from, the way that *ixes work; Windows first compares what you've
> typed with the list of commands built-in to CMD, then with all of the
> executable files in the current working directory, THEN
> walks through the directories listed in PATH.  The first matching
> command or executable it finds is the one that runs.
>
>> Putting #!python3 on the first line of game_over2.py should solve it.
> NO.  #! has no effect in Windows, because the choice of Python
> interpreter has already been made by the time anybody gets round to
> reading the first line of the file.

"#!python3.4" or "#!C:\Python34\python.exe" or "#!/usr/bin/env
python3" should all work if the '.py' extension is properly associated
with the py.exe launcher, which it should be if the most recently
installed Python was 3.3 or 3.4, installed with default options.

-- 
Zach

[1] http://legacy.python.org/dev/peps/pep-0397/
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to