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

Mike Müller mmueller at python-academy.de
Mon Sep 15 16:56:10 CEST 2014


Am 15.09.14 15:46, schrieb Steven D'Aprano:
> On Mon, Sep 15, 2014 at 11:50:26AM +0200, Mike Müller wrote:
> 
>> In general, I think the single most useful improvement for beginners are
>> better hints in error message about what possibly went wrong.
>>
>> If this goes beyond syntax errors, adding a switch to turn this off might
>> be useful. Just in case somebody actually scrapes messages or your doctests
>> break.
> 
> The exact exception message is not a part of the public API of Python 
> built-ins or the standard library, so any code which relies on that is 
> wrong. Error messages are subject to change without notice. As for doc 
> tests, the doctest module has a directive specifically for ignoring the 
> exception error message:
> 
> https://docs.python.org/3/library/doctest.html#doctest.IGNORE_EXCEPTION_DETAIL
> 
> Just add  #doctest:+IGNORE_EXCEPTION_DETAIL  to your test, and the 
> message will be ignored.

Thanks for the hints. Actually, I am familiar with both points.
Even though quite a bit ugly code is out there, it maybe better to enforce
good programming style instead of adding switches that allow such code to run.
So, no switch.

Mike



More information about the Python-ideas mailing list