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

Maxime Steisel maximesteisel at gmail.com
Tue Aug 5 09:48:14 CEST 2014


Le 2014-08-05 02:07, "Greg Markham" <greg.markham at gmail.com> a écrit:
>  Ok, when I try this from the Shell window, it works.  When executing the
full program from command line, it does not.  Python versions from both
shell and command line are 3.4.1 (confirmed via command: "python -V").
>
> Full error msg output when run from cmd line reads:
>
>   File "I:\Programming\Scripts\Learning\chapter02\game_over2.py", line 14
>
>     print("Here", end=" ")
>                      ^
> SyntaxError: invalid syntax
>

That definitely show that python2 is running.

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.
Putting #!python3 on the first line of game_over2.py should solve it.

See PEP 397 [1] for more details about this feature.

[1] http://legacy.python.org/dev/peps/pep-0397/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140805/57a062a8/attachment-0001.html>


More information about the Tutor mailing list