Hey, I'm new to python so don't judge.

Terry Reedy tjreedy at udel.edu
Wed Jan 4 01:21:54 EST 2017


On 1/3/2017 10:15 PM, Dennis Lee Bieber wrote:

> And that statement tells us you are trying to run from within some
> IDE/editor which is trapping Python exceptions and producing a dialog
> box for them.

IDLE does this when one runs code from the editor, because it
cannot/should not inject error messages into the editor buffer... AND it 
replaces the ^ with red highlighting of the code pointed to.  No
information is lost.  Apparently, some beginners do not see the connection 
between the SyntaxError box and the red highlighting.  I think I should add 
something to the box.  Maybe 'The error was detected at the point of the red 
highlighting.'

> Instead, save your script (if you haven't yet) as a file
> (whatever.py).
>
> Open a command line interpreter/shell.
>
> Navigate (cd ...) to where you saved the file
>
> Type "python whatever.py"

What a nuisance.

> Copy and paste the results of the CLI/Shell window.

Or one can hit F5 to run the code or Alt-X to just check the syntax. A beginner 
should do this every few lines, and it should be as easy as possible to check.  
If one needs to ask about a syntax error, one can copy the code up and 
including the highlighted part. Example:

"When I run this code in IDLE

def is_same(target, number:
         if

I get a SyntaxError at 'if'."

If the OP had known to do this, the error might have been seen without posting.

--
Terry Jan Reedy




More information about the Python-list mailing list