[Python-ideas] Break the dominance of boolean values in boolean context

Paul Moore p.f.moore at gmail.com
Tue Sep 13 18:02:01 CEST 2011

On 13 September 2011 16:05, Lukas Lueg <lukas.lueg at googlemail.com> wrote:
> 2011/9/13 Ron Adam <ron3200 at gmail.com>:
>> On Mon, 2011-09-12 at 21:40 -0400, Devin Jeanpierre wrote:
>>> Can we not allow things like `a < b` to return non-boolean values,
>>> without altering the behaviour of existing Python types?
>> Would that return 'a' or 'b', or something else?
> That depends on the object at hand. 'a < b' could return 'b - a' for
> set-like objects. Read 'a < b' as the answer to the question 'how much
> bigger is b than a?'.

Maybe I'm being dense, but why would I read it like that? The
operation a < b means "is a less than b?" That's not a matter of
opinion, as far as I can see, that's basically the definition of "<".
You could certainly overload < to mean something else for particular
types, but that's not something to do lightly (look at C++'s use of <<
for IO, for a relatively benign example of both the benefits and
problems with such an approach...)


More information about the Python-ideas mailing list