Syntax error for simple script

Adriaan Renting renting at astron.nl
Wed Jun 28 03:51:17 EDT 2017




Adriaan Renting        | Email: renting at astron.nl
Software Engineer Radio Observatory
ASTRON                 | Phone: +31 521 595 100 (797 direct)
P.O. Box 2             | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 595 101
The Netherlands        | Web: http://www.astron.nl/~renting/



>>> On 27-6-2017 at 21:38, Erik <python at lucidity.plus.com> wrote: 
[snip]
> 
> One other possibility is that a beginner fires up Py3 and gets that 
> "weird" (to them) error when they tried their tutorial or SO code and

> then finds out that if they fire up Py2 instead it just works. Now
they 
> might continue to use Py2 because it's "the one that works" for
them.
> 
> I would suggest that making the error dissuade them from doing that
(for 
> the cost of a few tens of bytes) is a good thing.
> 
>>> I think the suggestion above is a bit wordy, but even if it was
>>> something like "Missing parentheses in call to the 'print'
function"
>> 
>> I think this is a good example of "the curse of knowledge". Its hard
for 
> expert > to think like a non-expert.
> 
> [snip]
> 
>> But to the beginner, adding "function" at the error might as well
be
>> 
>> Missing parentheses in call to the 'print' wharrgarbl.
> 
> You are concentrating on the detail of what I wrote. I don't care
what 
> the eventual wording is (and for sure, someone else is far more 
> qualified than me to suggest wording that is better for a beginner).
My 
> point is simply that the error _could_ contain _some_ more
information 
> that addresses this issue for a beginner who may be typing in Py2 
> examples that encourages them to seek out Py3 tutorials instead.
> 
>> That's why I asked Ben if there was something we
>> could do to make the sentence clearer.
> 
> Exactly. Ben is an example of someone more qualified than me to
suggest 
> the correct words.
> 
>>> Either that or just make it "SyntaxError: invalid syntax" like all
the
>>> others.
>> 
>> We've been there: adding the specific print message is new to Python
3.5 (or
>> maybe 3.4, I forget which). Python 3.3 gives just "SyntaxError:
invalid
>> syntax".
> 
> That surprises me, to be honest. I had presumed that the parser had
just 
> had the machinery for that message placed where the 'print' keyword
used 
> to be handled rather than ripping the whole thing out when it became
a 
> function. Interesting that it's a retrospective special case.
> 
> E.

I agree in general with Erik. I don't like the general SyntaxError. I
like more specific errors that you can at least google for.
I don't think you need the whole history in the error, but it would be
nice if it was specific enough that if you put it in a search engine you
get relevant results explaining things.

A.



More information about the Python-list mailing list