Show off your Python chops and compete with others
Roy Smith
roy at panix.com
Thu Nov 7 20:54:05 EST 2013
In article <l5hfuj$m2n$1 at dont-email.me>, alex23 <wuwei23 at gmail.com>
wrote:
> On 8/11/2013 11:02 AM, Roy Smith wrote:
> > Well, if you want to be truly pedantic about it (*), this defines a
> > function without an explicit return and which does not return None:
> >
> > def foo():
> > raise Exception
>
>
> In [2]: import dis
> In [3]: dis.dis(foo)
> 2 0 LOAD_GLOBAL 0 (Exception)
> 3 RAISE_VARARGS 1
> 6 LOAD_CONST 0 (None)
> 9 RETURN_VALUE
>
> Seeing as we're being pedantic, the function *does* return None, it's
> just that the return value is never seen because an exception is raise.
Dead code doesn't count.
More information about the Python-list
mailing list