Syntax error for simple script
boB Stepp
robertvstepp at gmail.com
Tue Jun 27 12:52:29 EDT 2017
On Tue, Jun 27, 2017 at 9:05 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> On Tue, 27 Jun 2017 08:34 am, Erik wrote about the print function error message:
>
> py> print x
> File "<stdin>", line 1
> print x
> ^
> SyntaxError: Missing parentheses in call to 'print'
[snip]
>> 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 experts
> to think like a non-expert.
>
> It seems obvious to us that adding the word "function" will make it clear to the
> user what's going on. We understand that print is now a function, and function
> calls always need parentheses, but that print used to be a statement like
> while, for, if, etc. that doesn't need parentheses.
>
> To a moderately experienced programmer, the word "function" doesn't actually add
> anything, but it isn't harmful: the error is just a reminder of what they
> probably already know.
>
> But to the beginner, adding "function" at the error might as well be
>
> Missing parentheses in call to the 'print' wharrgarbl.
>
>
> It's just jargon. They can either diagnose the problem from the first part of
> the sentence telling them that there are missing parentheses, or they can't. If
> they can't, I doubt that adding the word "function" (or any other jargon term
> like subroutine, procedure or callable) will help.
>
> Anyway, that's my opinion. If any newbies, like the OP, would like to venture an
> opinion, that would be good. That's why I asked Ben if there was something we
> could do to make the sentence clearer.
Perhaps add a simple usage example?
SyntaxError: Missing parentheses in call to 'print'. Correct example:
print('Prints this string')
Surely a little more verbiage won't be too harmful?
--
boB
More information about the Python-list
mailing list