syntax error in first-time user script

Terry Reedy tjreedy at udel.edu
Fri Mar 24 12:55:23 EDT 2017


On 3/23/2017 9:57 PM, john polo wrote:

> If I use IDLE shell:
>
> "python comment.py"
>
> "SyntaxError: invalid syntax"

IDLE's Shell runs your input with nearly identical results as with the 
standard interactive interpreter, including exceptions.

> I know I can open the file in the editor and use F5, but shouldn't I be
> able to use a command from shell?

No.  You enter Python statements, not terminal commands.

 > How do I run comment.py from a command line without error?

At the Command Prompt window's prompt, such as 'C:\user\you>', enter

python path/to/comment.py

The path shown before the prompt char, '>', is the 'current working 
directory'.  Learn to use the 'cd' command.

-- 
Terry Jan Reedy




More information about the Python-list mailing list