Overriding logical operators?
adurdin at gmail.com
Sat Aug 21 07:39:52 CEST 2004
In Python, you can override the behaviour of most operators for a
class, by defining __add__, __gt__, and the other special object
I noticed that, although there are special methods for most operators,
they are conspicuously absent for the logical "or" and "and". I'm
guessing that the reason for this is that these operators
short-circuit if their first operand answers the whole question?
Would it be possible to allow overriding the logical operators, with
the caveat that overriding it would prevent short-circuiting?
More information about the Python-list