Pass and return
Duncan Booth
duncan.booth at invalid.invalid
Fri Dec 21 03:52:43 EST 2012
Mitya Sirenef <msirenef at lightbird.net> wrote:
> On 12/21/2012 12:23 AM, iMath wrote:
>> Pass and return
>> Are these two functions the same ?
>>
>> def test():
>> return
>>
>> def test():
>> pass
>
>
> From the point of style, of course, the latter is
> much better because that's the idiomatic way
> to define a no-op function. With a return, it
> looks like you might have forgotten to add the
> value to return or deleted it by mistake.
>
I would say it is *an* idiomatic way to define a no-op function.
Another idiomatic way is to use a doc-string as the only body,
that way you can also explain why you feel the need for an empty
function.
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list