On 13 September 2016 at 23:55, Donald Stufft <[email protected]> wrote:
> Perhaps a better idea would be to add some smarts to the REPL (but not to
> Python itself) that would detect something like:
>
>>>> pip install
>
> And print a better error message that gives a better indication about what’s
> gone wrong besides a SyntaxError?
This is pretty easy to do:
def excepthook(typ, value, traceback):
# Tidy this up to suit
if typ is SyntaxError and value.text.startswith("pip"):
print("You may want to run this from a shell prompt")
return
sys.__excepthook__(typ, value, traceback)
sys.excepthook = excepthook
Of course, it doesn't solve the problem of a user who doesn't know
what a "shell prompt" is...
Paul
_______________________________________________
Distutils-SIG maillist - [email protected]
https://mail.python.org/mailman/listinfo/distutils-sig