On 12/21/2012 03:52 AM, Duncan Booth wrote:
Mitya Sirenef <msire...@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.
That's true, a docstring is preferable in many cases. -m
--
Lark's Tongue Guide to Python: http://lightbird.net/larks/
--
http://mail.python.org/mailman/listinfo/python-list