Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!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; ';-)': 0.03; 'subject:Python': 0.06; 'definitions': 0.07; 'explicit': 0.07; 'defines': 0.09; 'except:': 0.09; 'shifting': 0.09; 'try:': 0.09; 'wrapper': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '**kwargs)': 0.16; '**kwargs):': 0.16; '-tkc': 0.16; 'bytecode': 0.16; 'foo()': 0.16; 'foo():': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'function"': 0.16; 'none.': 0.16; 'roy': 0.16; 'sequence,': 0.16; 'statement.': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'hacking': 0.19; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'skip': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'raise': 0.29; 'statement': 0.30; "i'm": 0.30; 'could': 0.34; 'subject:with': 0.35; 'beyond': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'possible': 0.36; 'that,': 0.38; 'does': 0.39; 'sure': 0.39; 'stand': 0.64; 'smith': 0.68; 'subject:your': 0.76; 'received:50.22': 0.84 Date: Thu, 7 Nov 2013 22:05:14 -0600 From: Tim Chase To: Roy Smith Subject: Re: Show off your Python chops and compete with others In-Reply-To: References: <82328ec8-7178-4a17-abfe-13d444fab9cf@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com Cc: python-list@python.org 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383883428 news.xs4all.nl 15956 [2001:888:2000:d::a6]:33220 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58746 On 2013-11-07 21:18, Roy Smith wrote: > It's not a shifting goalpost. My original statement was that: > > def foo(): > raise Exception > > defines a function which 1) has no explicit return statement and 2) > does not return None. I stand by that statement. There is no > possible codepath, no possible calling sequence, no possible > execution environment, which will cause that function to return > None. Well, for varying definitions of "that function", you can do >>> def unerr(fn): ... def wrapper(*args, **kwargs): ... try: ... fn(*args, **kwargs) ... except: ... return None ... return wrapper ... >>> @unerr ... def foo(): ... raise Exception ... >>> print foo() None ;-) Beyond that, I'm sure one could resort to bytecode hacking to have "that function" skip the raise... -tkc