Hacker News new | past | comments | ask | show | jobs | submit login

The hardest thing for me to understand in Python was the baffling tendency of methods to return None.



I 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.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: