Other difference with Perl: Python scripts in a pipe

Ethan Furman ethan at stoneleaf.us
Fri Mar 11 03:55:55 EST 2016


On 03/10/2016 04:26 PM, Fillmore wrote:
> On 3/10/2016 7:08 PM, INADA Naoki wrote:
>
>> No.  I see it usually.
>>
>> Python's zen says:
>>
>>> Errors should never pass silently.
>>>     Unless explicitly silenced.
>>
>> When failed to write to stdout, Python should raise Exception.
>> You can silence explicitly when it's safe:
>>
>> try:
>>      print(...)
>> except BrokenPipeError:
>>      os.exit(0)
>>
>
> I don't like it. It makes Python not so good for command-line utilities

You don't like typing two extra lines of code?

Or don't you like needing to understand what is going on so you know 
when to silence errors?

The try/except paradigm is very useful -- it's worth learning.

--
~Ethan~



More information about the Python-list mailing list