Proto-PEP: Overloadable Boolean Operators
adurdin at gmail.com
Tue Sep 7 08:03:42 CEST 2004
On Tue, 07 Sep 2004 16:37:18 +1200, Greg Ewing
<greg at cosc.canterbury.ac.nz> wrote:
> Alex Martelli wrote:
> > Problem is, __nonzero__ is currently
> > typechecked -- it has to return an integer.
> Yes, that's the problem. I should probably elaborate
> on that a bit in the PEP.
That is not the only issue with __nonzero__ versus __not__ -- in some
cases (e.g. the symbolic algebra or SQL query constructor) it is
useful to determine when an explicit "not" operator has been used.
I'm not at a machine with the patch installed on it at the moment, but
I just began to whether this patch would have an effect on expressions
like (a < b < c) (which are also short-circuiting)... Come to think
of it, how do objects which override __gt__ and the other comparisons
(particularly for expression construction) work in that case?
More information about the Python-list