Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ethan Furman Newsgroups: comp.lang.python Subject: Re: Other difference with Perl: Python scripts in a pipe Date: Fri, 11 Mar 2016 00:55:55 -0800 Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de nCUxjd8XttNUczStz8ilug8nOALwX++XsyYPY+3KeTEw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'exception.': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'python': 0.10; 'explicitly': 0.15; 'code?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'try/except': 0.16; 'usually.': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'typing': 0.18; '>>>': 0.20; 'pass': 0.22; 'errors': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'command-line': 0.29; 'silence': 0.29; '~ethan~': 0.29; 'raise': 0.29; 'useful': 0.33; 'except': 0.34; 'should': 0.36; 'lines': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'no.': 0.62; 'charset:windows-1252': 0.62; 'needing': 0.63; 'worth': 0.67; 'zen': 0.84 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104593 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~