"return" in def

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Mon Dec 29 07:23:08 EST 2008


John Machin a écrit :
> On Dec 29, 8:26 pm, Bruno Desthuilliers <bruno.
> 42.desthuilli... at websiteburo.invalid> wrote:
>> John Machin a écrit :
(snip)
>>> Please don't. Follow MRAB's advice, with the corollary that a
>>> generator is forced by the compiler to be a "procedure" in MRAB's
>>> terminology.
>> I fail to see any *practical* difference between MRAB's and Steven's
>> POVs. In both cases, it boils down to
>> - don't use a bare return at the end of a def statement's body,
>> - either use only bare returns ('procedure') or explicitely return None
>> ('function')
> 
> Steven's treatment was somewhat discursive, and didn't explicitly
> mention the 'procedure' possibility. In fact, this sentence "if you
> have a function with early exits, and you need to make the intent of
> the function clear, explicitly return None." would if applied to a
> 'procedure' cause a stylistic horror as bad as a bare return at the
> end of the def.

Ok. You're right.



More information about the Python-list mailing list