A
Andrew Durdin
In Python, you can override the behaviour of most operators for a
class, by defining __add__, __gt__, and the other special object
methods.
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?
class, by defining __add__, __gt__, and the other special object
methods.
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?