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

Python allows the overriding of just about every operator. For Pathlib they overrode the division operator to instead perform path addition in a platform agnostic manner.



> Python allows the overriding of just about every operator.

Except the boolean operators (and, or, not). For instance __and__ overrides the binary and (&), not the boolean and.


That's True, but you _can_ override __bool__.[1]

[1] https://docs.python.org/3/reference/datamodel.html#object.__...




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: