Old Man Yells At Cloud

Steve D'Aprano steve+python at pearwood.info
Wed Sep 20 13:27:48 EDT 2017


On Thu, 21 Sep 2017 01:06 am, Dennis Lee Bieber wrote:

> On Wed, 20 Sep 2017 10:08:18 +1000, Steve D'Aprano
> <steve+python at pearwood.info> declaimed the following:
> 
>>For what its worth: from Python 3.5 (I think) onwards the error you get is
>>customized:
>>
>>py> print 1
>>  File "<stdin>", line 1
>>    print 1
>>          ^
>>SyntaxError: Missing parentheses in call to 'print'
>>
> 
> So... "print" (the function") is still a special case for the
> interpreter...


One of Python's weaknesses is that many error messages are fairly obscure and
uninformative, and the devs are trying to fix that. If that means treating some
things as "special cases", so be it, because practicality beats purity.

But yes, print is specifically a special case because of its history in Python
2. And for exactly the same reason, exec() is also special-cased:

py> exec '1'
  File "<stdin>", line 1
    exec '1'
           ^
SyntaxError: Missing parentheses in call to 'exec'



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