[New-bugs-announce] [issue45721] Improve error message when python shell command is entered at the REPL prompt

Steven D'Aprano report at bugs.python.org
Thu Nov 4 21:53:40 EDT 2021


New submission from Steven D'Aprano <steve+python at pearwood.info>:

A frequent newbie mistake is to call shell commands from inside the interactive interpreter. Most common is to call Python itself.

Here is an example where a Python instructor was allegedly unable to diagnose the issue for their students:

https://windowsquestions.com/2021/10/09/syntaxerror-invalid-syntax-perhaps-you-forgot-a-comma/


I think it would be a nice feature if the compiler recognised obvious cases of "user tried to call Python from the Python prompt", and suggested a fix. If the statement matches the regex r"python\s+" the error message might say "it looks like you are trying to run a shell command at the Python prompt" rather than suggest a missing comma.

----------
messages: 405764
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: Improve error message when python shell command is entered at the REPL prompt
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45721>
_______________________________________


More information about the New-bugs-announce mailing list