Syntax error for simple script

Steve D'Aprano steve+python at pearwood.info
Tue Jun 27 22:46:57 EDT 2017


On Wed, 28 Jun 2017 05:38 am, Erik wrote:


[...]
> So I don't understand the resistance to making the error be a bit more
> explicit about why it is being generated to help those users - it
> doesn't explain (the obvious reason) _why_ their tutorial/example gives
> them an error when it doesn't to the person who wrote the tutorial.

All of this is irrelevant if beginners don't read the error message. End-users
don't read error messages, no matter how well written they are, and every word
you add probably cuts the number of people reading it by half.

Newbie programmers are more like end-users than seasoned programmers. Learning
to read the error message is a skill that must be taught and learned. Part of
the learning process is to explain the why, the when, the how, and perhaps even
the history of the error. That's not something needed in the error message
itself (imagine how annoying it would be if ZeroDivisionError tried to explain
the basis of arithmetic and why you can't divide by zero), and rather than
helping the newbie, it will probably intimidate them and make it even less
likely to read and understand the error.

When designing an error message, imagine that you are going to read it a dozen
times a day, every day, for the rest of your career.


> 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.

The cost isn't ten bytes. The cost is human attention span.

Don't think of the newbie reading the error for the first time, because that
only happens *once*. Think of them reading it for the 50th time. Do you think
they will still appreciate your little history lesson?


> 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.

Of course it could. It could also include a link to the Python documentation, a
history of how and why Python 3000 came to be, and a note that if you email the
Python Software Foundation they'll pay you $50, and none of these things will
make the slightest difference if people don't read them.

It's not a question of what the error message *could* say, its what it *should*
say, and more is not always better.

I think that there are broadly two sets of newbies in the world:

- those who will read the message, and be able to resolve the problem from the
current wording ("oh, it needs parentheses, like a function");

- and those who won't, in which case adding more words to the message won't help
in the slightest.


>> 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.

And is typical, Ben has not (as far as I can see) replied. Which I take as an
answer to my question: no, he did not read the error message, or spend more
than a millisecond trying to understand it, and adding more words wouldn't have
changed that in the slightest.

"Cynical" is what Pollyannas call realists :-)



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list