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 -- https://mail.python.org/mailman/listinfo/python-list