"return" in def

Gerard Flanagan grflanagan at gmail.com
Sun Dec 28 18:56:23 CET 2008


On Dec 28, 5:19 pm, Roger <rdcol... at 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.

G.



More information about the Python-list mailing list