"return" in def

r rt8396 at gmail.com
Sun Dec 28 12:33:19 EST 2008


On Dec 28, 11:19 am, Roger <rdcol... at gmail.com> wrote:
> Hi Everyone,
>
> First I want to thank everyone that posts to this group.  I read it
> daily and always learn something new even if I never feel like I have
> anything to contribute but my questions.
>
> 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.
>
> Even when I'm not explicitly returning something I like to add
> "return" because it's a good additional visual marker for me to see
> where a method definition ends especially in cases where I may use a
> nested method.
>
> Thanks for the discussion!
> Roger.

returning nothing does nothing :)



More information about the Python-list mailing list