[Tutor] New to Python - print function - invalid syntax

Mark Lawrence breamoreboy at yahoo.co.uk
Tue Aug 5 17:20:39 CEST 2014


On 05/08/2014 15:56, Marc Tompkins wrote:
> On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel <maximesteisel at 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.
> 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.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

Completely wrong, the reference that Maxime gave to PEP 397 that you've 
snipped was absolutely correct.  Windows might not handle shebang lines, 
Python on Windows does.



More information about the Tutor mailing list