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:44:06 +0300 Organization: A noiseless patient Spider Lines: 30 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="11964"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/v43SRhC6ZRMtyXV/2/uomdapY9BE8Hgs=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:D1tT9QrAEDvt4i53W9hEmsJUbZY= sha1:V/GT4vczAmMko5ACa/umDrTCUJw= Xref: csiph.com comp.lang.python:96781 Chris Angelico writes: > On Fri, Sep 18, 2015 at 4:49 AM, Ian Kelly wrote: >> 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 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. Yes, that's what I was trying to say, though I should have used the word "operation" not "operator". The operators that denote something like operations are routinely used to feed their values back to the same or related operations; doing that with truth-valued operators does not often make sense; their results are combined with and, or, and not instead. I can easily make up special cases myself, but now I'm trying to think of typical uses and say that Python got this quite right.