3 ms·
The hardest thing for me to understand in Python was the baffling tendency of methods to return None.
by disgruntledphd2 4y ago
The hardest thing for me to understand in Python was the baffling tendency of methods to return None.
- teddyh 4y agoI think I have read somewhere that they return None in order to explicitly signal that the object has been modified in-place. For example, if you want to have one method which sorts in-place, and another which returns a sorted copy, if then both methods returned a sorted object, it would be too easy to mistakenly call one instead of the other, creating a bug which might not be found for years.