Roger a écrit :
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?
If it's the last statement in the function body, it is indeed "excessive".
OTHO I sometimes end a function with an explicit "return None" when
there are branches with early returns, ie:
def func():
if some_condition:
return something
return None
to make really clear what happens - even if it _should_ be clear without
the last statement. IOW : use your own judgement.
--
http://mail.python.org/mailman/listinfo/python-list