True == 1 weirdness

Chris Angelico rosuav at
Thu Sep 17 20:57:42 CEST 2015

On Fri, Sep 18, 2015 at 4:49 AM, Ian Kelly <ian.g.kelly at> wrote:
> On Thu, Sep 17, 2015 at 1:06 AM, Jussi Piitulainen
> <harvesting at> wrote:
>> Ordinary binary operators not only combine things of the same type, they
>> also produce a thing of that same type. So 'in' does not fit among them
>> either.
>> I feel it's _more_ at home among comparison operators. (Hm. That's
>> 'operator' in a different sense.)
> Comparison operators *are* binary operators. All that "binary" means
> is that it takes two arguments.

I think what Jussi is saying is that int+int yields int, and
float*float yields float, and so on - but even that is true only of
the arithmetic operators, and not all of them (int/int -> float in
Py3). But generalizing from "arithmetic operators" to "ordinary
operators" is a little unfair, unless you assume that the sole purpose
of programming is to represent algebra.


More information about the Python-list mailing list