Apr-30-2017, 05:46 AM
(Apr-30-2017, 05:36 AM)Skaperen Wrote: i did do an explicit return None in the __init__ method per post #8. is there a reason you believe in that suggests or mandates that an implicit None is better, as in just return?Not as in just
return
. As in nothing. Function end. Any function without a return statement returns None.The reasoning is simply that no one explicitly writes returns for
__init__
or functions that simply alter mutables. That is all I can offer you. Yes, generally explicit is better than implicit. This is not one of those cases.The only thing stated about
return None
in pep8 is that if you have another non-None return in the same function the return None
should be explicit. I would argue that even this is rare however. Usually you should raise an exception in cases like this rather than returning None for the exceptional case.