Gerard Flanagan wrote:
On Dec 28, 5:19 pm, Roger <rdcol...@gmail.com> wrote:
Hi Everyone,
[...]
When I define a method I always include a return statement out of
habit even if I don't return anything explicitly:

def something():
        # do something
        return

Is this pythonic or excessive?  Is this an unnecessary affectation
that only adds clock ticks to my app and would I be better off
removing "returns" where nothing is returned or is it common practice
to have returns.


It's not particularly excessive but it is uncommon. A nekkid return
can sometimes be essential within a function body, so a non-essential
nekkid return could be considered just noise.

If it's a function, ie the result is used by the caller, then explicitly return with the value, even if it's None. On the other hand, if it's a procedure, ie the result is always None and that result isn't used by the caller, then don't use return, except for an early exit.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to