Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: Why not allow empty code blocks? Date: Fri, 29 Jul 2016 15:55:07 +0200 Lines: 23 Message-ID: References: <5792cd34$0$1587$c3e8da3$5496439d@news.astraweb.com> <87vazwppxx.fsf@elektro.pacujo.net> <579B1ABB.1070500@rece.vub.ac.be> <20160729071458.1dfa170f@imp> <579b5d8c$0$1615$c3e8da3$5496439d@news.astraweb.com> <579B603B.60102@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de JycEa1AaJQoMs0TUhr5pygDE0cqhGsisTTMx55YiTRYg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'handler': 0.04; 'received:134': 0.05; 'clause': 0.07; 'processing.': 0.07; 'subject:code': 0.07; 'exception,': 0.09; 'subject:Why': 0.09; 'subject:not': 0.11; 'exception': 0.13; 'ignore': 0.14; 'folks': 0.15; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:allow': 0.16; 'try:': 0.18; 'replacing': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'error': 0.27; 'handling': 0.27; 'logging': 0.27; 'block,': 0.29; 'code': 0.30; 'received:be': 0.30; 'useful': 0.33; 'purposes,': 0.33; 'steven': 0.33; 'except': 0.34; 'handle': 0.34; 'replace': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'seem': 0.37; 'why': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'claim': 0.61; 'course': 0.62; 'information': 0.63; 'times': 0.63; 'soon': 0.65; 'believe': 0.66; 'rare': 0.66; "d'aprano:": 0.84; 'pardon': 0.84; 'schreef': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DwGQDQX5tX/0YPuIZdhGUBuzUBhhwCgXgBAQEBAQFehQQBBSNmCxoCBSECAg8CRhMIAogtrlWKBhqDTwEBCAIlgQGFKYRNhQyCNYJaBZkzgWCNHolGhXqQKVSDfIhXAQEB X-IPAS-Result: A2DwGQDQX5tX/0YPuIZdhGUBuzUBhhwCgXgBAQEBAQFehQQBBSNmCxoCBSECAg8CRhMIAogtrlWKBhqDTwEBCAIlgQGFKYRNhQyCNYJaBZkzgWCNHolGhXqQKVSDfIhXAQEB User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 In-Reply-To: <579b5d8c$0$1615$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <579B603B.60102@rece.vub.ac.be> X-Mailman-Original-References: <5792cd34$0$1587$c3e8da3$5496439d@news.astraweb.com> <87vazwppxx.fsf@elektro.pacujo.net> <579B1ABB.1070500@rece.vub.ac.be> <20160729071458.1dfa170f@imp> <579b5d8c$0$1615$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:112018 Op 29-07-16 om 15:43 schreef Steven D'Aprano: > Of course it won't, which is why I don't believe all these folks who claim > that they regularly ("all the time", "fairly often") replace except blocks > with `pass`. I call shenanigans -- perhaps you do it *occasionally*, but as > a general rule, you can rarely replace the exception handler with a > do-nothing clause and expect your code to work: > > try: > block > except SomeException: > handle error > process > > If you remove the error handling block, replacing it with `pass`, in general > your code will just break again as soon as it continues processing. I think the case where you just want to ignore the exception, but it can at times be useful to get some extra logging information for debuging purposes, is not that rare as you seem to suggest. -- Antoon Pardon