Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jussi Piitulainen Newsgroups: comp.lang.python Subject: Re: True == 1 weirdness Date: Thu, 17 Sep 2015 23:24:06 +0300 Organization: A noiseless patient Spider Lines: 39 Message-ID: References: <0b949fe0-09b4-46b0-b4ac-a85a9bfebfd5@googlegroups.com> <1442412230.1762717.385286049.20841F36@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="7646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+csoVNjMFYymWkOT20mYxCNRW/50iMH0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:LxwG0/GnN4kr+iszsOSJ35iYzyI= sha1:sNS10aZsNs8kU9o1udlelFh7lVs= Xref: csiph.com comp.lang.python:96780 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.