You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See discussion here. Note that the code sample sent by Ron was correctly formatted in email, but has lost all indentation in the Discuss website.
Rename the attached noblank.txt to noblank.py. (Github will not allow you to upload .py files!)
Run the renamed noblank.py file from the command line, e.g. python3.10 noblank.py. Note that it will run correctly from the vanilla Python interpreter. But it fails if copied and pasted into the interactive interpreter or IDLE.
Steps to reproduce
Launch IDLE, or the CPython interactive interpreter.
Copy the contents of noblank.py using your preferred text editor.
Paste it at the >>> prompt.
The interactive interpreter and IDLE both report a syntax error: SyntaxError: invalid syntax.
Expected behaviour
Preferably, the code should run and print "no blank" as it does in the non-interactive interpreter. If that is not possible, it should report a better error message, such as mentioning an unexpected outdent and suggesting that a blank line should be inserted.
(Stephen, please don't put 3 line examples in a separate file. Use a triple-backquoted block like Andre' did.)
In interactive mode, one must enter a single statement for each primary prompt. The example has 2 statements. Compound statements must be terminated with a blank. From Tutorial 3.2: "When a compound statement is entered interactively, it must be followed by a blank line to indicate completion (since the parser cannot guess when you have typed the last line)." The error is correct.
Uh oh!
There was an error while loading. Please reload this page.
See discussion here. Note that the code sample sent by Ron was correctly formatted in email, but has lost all indentation in the Discuss website.
Rename the attached noblank.txt to noblank.py. (Github will not allow you to upload .py files!)
Run the renamed noblank.py file from the command line, e.g.
python3.10 noblank.py
. Note that it will run correctly from the vanilla Python interpreter. But it fails if copied and pasted into the interactive interpreter or IDLE.Steps to reproduce
>>>
prompt.SyntaxError: invalid syntax
.Expected behaviour
Preferably, the code should run and print "no blank" as it does in the non-interactive interpreter. If that is not possible, it should report a better error message, such as mentioning an unexpected outdent and suggesting that a blank line should be inserted.
noblank.txt
The text was updated successfully, but these errors were encountered: