3 ms·
I would add overriding boolean dunder methods: __and__, __or__, __xor__ dunder methods. Even more rare is overriding bitwise shift operations: __rshift__, __ls
by pyuser583 4y ago
I would add overriding boolean dunder methods: __and__, __or__, __xor__ dunder methods.
Even more rare is overriding bitwise shift operations: __rshift__, __lshift__ etc. This is unfortunate, as these methods are only natively implemented in integers, so they’re basically freebies.
- Kwpolska 4y ago> boolean dunder methods: __and__, __or__ Those are the bitwise operators (a & b, a | b). You can’t override the behavior of the boolean operators (a and b, a or b), you can only define the truthiness of your object with __bool__.