Author ncoghlan
Recipients ncoghlan
Date 2017-06-08.10:36:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496918206.6.0.484368054025.issue30597@psf.upfronthosting.co.za>
In-reply-to
Content
Back when we added the custom error message for missing parentheses in print calls, I also pre-seeded an explanation of the error on Stack Overflow: https://stackoverflow.com/questions/25445439/what-does-syntaxerror-missing-parentheses-in-call-to-print-mean-in-python/

While that does seem to be having the desired effect of explaining an otherwise cryptic message to people, William Brown pointed out that it could potentially be improved by taking advantage of the fact we have access to the rest of the line when working out the exact error text:

```
>>> print "Hello world!"
  File "<stdin>", line 1
    print "Hello world!"
                       ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean 'print("Hello world!")'?
```

The rationale for such a change is similar to the rationale for adding the custom error message in the first place: the folks most likely to hit this are either attempting to run a Python 2 script on Py3, or else attempting to follow a Py2 tutorial on Py3, and *telling* them what's wrong isn't as clear as *showing* them (by reprinting the line with the parentheses added)
History
Date User Action Args
2017-06-08 10:36:46ncoghlansetrecipients: + ncoghlan
2017-06-08 10:36:46ncoghlansetmessageid: <1496918206.6.0.484368054025.issue30597@psf.upfronthosting.co.za>
2017-06-08 10:36:46ncoghlanlinkissue30597 messages
2017-06-08 10:36:45ncoghlancreate