Closed
Description
Feature or enhancement
Proposal:
Previously the Python REPL only accepts either a single compound statement or a line of simple statements. For example, we can either do:
>>> def f():
... pass
...
>>>
or do:
>>> a = 1; a *= 3; print(a)
3
>>>
However, the REPL doesn't accept multiple consecutive compound statements, or any simple statement followed soon after a compound statement:
>>> def f():
... pass
... def g():
File "<stdin>", line 3
def g():
^^^
SyntaxError: invalid syntax
>>> def f():
... pass
... a = 1
File "<stdin>", line 3
a = 1
^
SyntaxError: invalid syntax
>>>
This will cause a lot of frustration when, for example, a user pastes snippet directly into the REPL and sees unexpected syntax error.
Hence, I propose to improve the parser, specifically the statement_newline
rule to accept the abovementioned cases.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response