|
|
|
|
|
by OJFord
1796 days ago
|
|
Woah! I was all ready to disagree with you, saying 'only for Boolean arguments'. In years of writing python I really thought `__and__`/`__or__` returned Boolean. (Of course they can, but for builtins I mean.) https://docs.python.org/3/reference/datamodel.html#emulating... It's not made clear here that I can see. Grr, needs type annotations! |
|
This is the correct part: https://docs.python.org/3/reference/expressions.html?highlig...
Edit: you can't override "and" and "or" with dunder methods.