Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'subject:Python': 0.06; 'finally:': 0.07; 'except:': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'valueerror:': 0.09; 'variant': 0.09; 'python': 0.11; 'language.': 0.14; 'exception:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'systemexit': 0.16; 'unexpected': 0.16; 'url:peps': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'url:dev': 0.24; 'looks': 0.24; 'references': 0.26; 'pass': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'url:bugs': 0.29; 'raise': 0.29; 'bug?': 0.31; 'url:python': 0.33; 'running': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'except': 0.35; 'anybody': 0.35; "who's": 0.35; 'version': 0.36; 'really': 0.36; 'url:org': 0.36; 'depends': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'ian': 0.60; "you're": 0.61; 'our': 0.64; 'subject:The': 0.64; 'finally': 0.65; 'charset:windows-1252': 0.65; 'bare': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: The Most Diabolical Python Antipattern Date: Sat, 31 Jan 2015 01:28:51 +0000 References: <20150129113238.7eaa986d@bigbox.christie.dr> <87r3uchjyg.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-24-222-48.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422667744 news.xs4all.nl 2843 [2001:888:2000:d::a6]:45132 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84928 On 30/01/2015 08:10, Mark Lawrence wrote: > On 30/01/2015 06:16, Marko Rauhamaa wrote: >> Ian Kelly : >> >>> At least use "except Exception" instead of a bare except. Do you >>> really want things like SystemExit and KeyboardInterrupt to get turned >>> into 0? >> >> How about: >> >> ============================== >> try: >> do_interesting_stuff() >> except ValueError: >> try: >> log_it() >> except: >> pass >> raise >> ============================== >> >> Surprisingly this variant could raise an unexpected exception: >> >> ============================== >> try: >> do_interesting_stuff() >> except ValueError: >> try: >> log_it() >> finally: >> raise >> ============================== >> >> A Python bug? >> >> >> Marko >> > > It depends on the Python version that you're running - I think!!! See > https://www.python.org/dev/peps/pep-3134/ > https://www.python.org/dev/peps/pep-0409/ > https://www.python.org/dev/peps/pep-0415/ and finally try (groan :) > https://pypi.python.org/pypi/pep3134/ > http://bugs.python.org/issue23353 looks like fun and references PEP3134 for anybody who's interested. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence