Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'mrab': 0.05; 'subject:Python': 0.06; 'binary': 0.07; '"if': 0.09; '*is*': 0.09; 'appropriate.': 0.09; 'mixed': 0.09; 'operand': 0.09; 'python': 0.11; 'directive': 0.16; 'footnote': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'operands': 0.16; 'other,': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'rule.': 0.16; 'simpson': 0.16; 'types,': 0.16; 'wrote:': 0.18; 'unlike': 0.19; 'header :User-Agent:1': 0.23; 'integer': 0.24; 'test.': 0.24; 'cheers,': 0.24; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; '[2]': 0.30; 'apparently': 0.31; 'forces': 0.31; 'guess': 0.33; 'convert': 0.35; 'equal': 0.35; 'good.': 0.35; 'received:com.au': 0.36; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'read': 0.60; 'numbers': 0.61; 'content-disposition:inline': 0.62; 'real': 0.63; 'different': 0.65; 'life': 0.66; 'between': 0.67; 'watching': 0.68; 'paper': 0.75; 'ending': 0.78 Date: Fri, 11 Oct 2013 08:52:43 +1100 From: Cameron Simpson To: python-list@python.org Subject: Re: I am never going to complain about Python again MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=YYGEuWhf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=9Lj92nWf6HwA:10 a=IkcTkHD0fZMA:10 a=vrnE16BAAAAA:8 a=8AHkEIZyAAAA:8 a=_Q_BDBVkwOwA:10 a=EBOSESyhAAAA:8 a=1u90lQbei-_3ok55YOkA:9 a=QEXdDO2ut3YA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381443400 news.xs4all.nl 15943 [2001:888:2000:d::a6]:60273 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56611 On 10Oct2013 17:48, Neil Cerutti wrote: > On 2013-10-10, MRAB wrote: > > If r is real (float) and c is complex: > > r == c means r == c.real and c.imag == 0.0 > > Woah. I thought I was going by what the docs say: > > Python fully supports mixed arithmetic: when a binary > arithmetic operator has operands of different numeric types, > the operand with the “narrower” type is widened to that of the > other, where integer is narrower than floating point, which is > narrower than complex. Comparisons between numbers of mixed > type use the same rule. [2] The constructors int(), float(), > and complex() can be used to produce numbers of a specific > type. > > [...] > > [2] Not for complex numbers. Instead convert to floats using > abs() if appropriate. > > I guess the "if appropriate" part eluded my eye. When *is* it > appropriate? Apparently not during an equal test. I must say that I read the footnote [2] as a directive to the programmer. "If you need to do this, a good way is to compare magnitudes is appropriate." Cheers, -- Cameron Simpson My life is a never ending battle for the forces of good. Unfortunately, unlike many other crusaders for righteousness, in my system of morality, the right thing to do is very often to sit around reading the paper or watching TV. - Tim_Mefford