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

Greg Markham greg.markham at gmail.com
Tue Aug 5 05:13:51 CEST 2014


On Mon, Aug 4, 2014 at 7:38 PM, Steven D'Aprano <steve at pearwood.info> wrote:

> On Mon, Aug 04, 2014 at 04:44:46PM -0700, Greg Markham wrote:
>
> >  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").
>
> I'm a little confused, because I consider "the shell" and "command line"
> to more or less be synonymous. Perhaps if you explain step-by-step what
> you do. Here's my guess of what you mean by "command line":
>
> Click on Start Menu.
> Choose "Run" command.
> Enter "cmd.exe"
> Enter "python I:\Programming\Scripts\Learning\chapter02\game_over2.py"
>
> Am I close?
>

For cmd line, yes that's basically it.  When I say "shell", I'm referring
to the Python IDLE GUI.


>
> > 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 looks like a Python 2 error, but it should work in any
> version of Python 3. This is a most perplexing error, I can only imagine
> that you have both Python 2 and 3 installed and somehow, for some
> unknown reason, you're sometimes getting one and sometimes getting the
> other.
>

That's correct, I did have two versions installed.  I first installed ver
2.7, then later installed ver 3.4 when I began going through the lessons in
the aforementioned book.  Although I'd taken steps to ensure the latest
version was used, I was apparently not thorough enough as when I inserted
some code in the program that revealed the version being used, it stated
2.7.4.  So, I ended up uninstalling both versions, then reinstalling ver
3.4 which reset the file associations and resolved the issue.

Hopefully any further issues I encounter aren't due to misconfigurations
and the like.

Thanks for your help, Steven.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140804/f4671be3/attachment.html>


More information about the Tutor mailing list