I wonder if it is bad manner to skip return None
, when it is not needed.
Example:
def foo1(x):
if [some condition]:
return B
To expound on what others have said, I use a return None
if the function is supposed to return a value. In Python, all functions return a value, but often we write functions that only ever return None, because their return value is ignored. In some languages, these would be called procedures.
So if a function is supposed to return a value, then I make sure all code paths have a return, and that the return has a value, even if it is None.
If a function "doesn't" return a value, that is, if it is never called by someone using its return value, then it's ok to end without a return, and if I need to return early, I use the bare form, return
.