[Python-ideas] Special-case 3.x 'print x' SyntaxError

Chris Angelico rosuav at gmail.com
Mon Sep 15 11:13:59 CEST 2014


On Mon, Sep 15, 2014 at 6:43 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> If we do this, I am sure someone will ask why we do not automatically
>> 'fix' the error.  One answer would be that the closing ) is needed to
>> determine the intended end of the call.  A longer version would be that
>> if we insert (, we are just guessing that the insertion is correct and
>> we still would not know, without guessing, where to put the ).
>
> Yes. Did you really mean "print spam", or should it be print_spam? Or
> print_(spam)? or prentspam? Fixing people's coding errors is not the
> job of the compiler -- DWIM code is dubious at best if not outright
> harmful.

Yeah, auto-fixing is a really dangerous thing. It might do the wrong
thing, and even if it does the right thing, it encourages sloppiness.
But I've seen plenty of error (or warning) messages that tell you what
the 99% likely fix is, and they're extremely helpful. I like those.

ChrisA


More information about the Python-ideas mailing list