Ian Kelly writes: > On Thu, Sep 17, 2015 at 1:06 AM, Jussi Piitulainen 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 confused two words. It's operation I meant, not operator. A binary _operation_ is defined as any map X * X -> X (by Lawvere and Schanuel, Lawvere and Rosebrugh, at least; let's allow division as close enough). (The asterisk stands for the Cartesian product. I'm too lazy to look up the proper Unicode character for it and not willing to see a non-ASCII symbol come back to me in a mangled form again anyway. Not today.) Then comparisons are not binary _operations_ except in a very restricted case. Their types are of the form X * X -> W, where W stands for a set of truth values, {True, False}. A comparison of truth-values could be taken as a binary operation, W * W -> W; other comparisons, under this definition, not. And I'm saying 'in', being truth-valued, is more like a comparison than a proper binary operation that has its value in the same set as its two arguments. Proper binary operations produce results that can be fed back to them, as in either ((x - y) - z) or (x - (y -z)). ((x < y) < z) or (x < (y < z)) does not usually make sense. ((x in y) in z) more or less fails. (x in (y in z)) fails. Just trying to explain what I had in mind when I said that I feel that 'in' is more at home with comparisons (where it is now) than with, hm, arithmetic operations. -- https://mail.python.org/mailman/listinfo/python-list