If I have a function which should perform an action on some condition, and returns null instead, which is cleaner:
def func():
if not condition:
return None
[...]
return asd
or
def func():
if condition:
[...]
value = asd
else:
value = None
return value
I've read the paradigm that every function should have one returning point. On the other hand the zen of python says that flat is better than nested and later version adds one nested level above the whole action code ( marked as [...]).
Please also bear in mind that conditions could be more complicated and for example, add more than one nesting level.