Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: for / while else doesn't make sense Date: Mon, 23 May 2016 01:32:07 +1000 Lines: 17 Message-ID: References: <573EC62F.4090401@lucidity.plus.com> <573f9322$0$1616$c3e8da3$5496439d@news.astraweb.com> <5741cde9$0$1587$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de lHA9kBTj2iPhiOrXDkLPhg/L+5Rdxyhacy3qLuUjX9Yg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'binary': 0.05; 'acceptance': 0.07; 'cc:addr:python-list': 0.09; 'subject:while': 0.09; 'python': 0.10; '0.2': 0.16; '2016': 0.16; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:74.125.82.46': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:3 30': 0.16; 'subject:make': 0.16; 'wrote:': 0.16; 'tells': 0.18; 'language': 0.19; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'saying': 0.22; 'am,': 0.23; 'header :In-Reply-To:1': 0.24; 'mon,': 0.24; "doesn't": 0.26; 'message- id:@mail.gmail.com': 0.27; '0.5': 0.29; "i'm": 0.30; "i'd": 0.31; 'option': 0.31; 'problem': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'that,': 0.34; 'received:google.com': 0.35; 'trouble': 0.35; 'returning': 0.35; 'something': 0.35; 'received:74.125.82': 0.35; "isn't": 0.35; 'problem.': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'doing': 0.38; 'some': 0.40; 'close': 0.61; 'subject: / ': 0.63; 'more': 0.63; 'fact,': 0.67; 'discover': 0.73; 'anywhere.': 0.84; 'chrisa': 0.84; 'subject:else': 0.84; 'subject:sense': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=2BPscXOCtodpcov8Jped10hRugqO3nq4WGUNEEhSXqs=; b=eLtVEJdj0upVQaERWng83xTWKhcmt17UI+mbVgJ3mxKEPhnT6cUecR7CdRLsePzPl4 OWPYfqiPcV52h42LikGvHHeLgMkokbDZMcUY0mtml258mc0pAc2AVzXgnX7KkgJgmB+o 7u45UjrWO/aG0dSTW+EJtuP67Ef5ZmIUJf5GJflGwdSNE5NwjeTozG3SR5dY3AhpWBsa ld77iyLHEBCUb0KXQTVOqa0kwUVeMipSjTOFEOr1I5sHXNF6z/blOgXH8CI6T5k+iFea GOjc7EmpT44iYkXXjTRTIx6TqPhzICTENfhBrLCVXDONAkiOJWXC6OUAc3GvpGD+uP8O WnCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=2BPscXOCtodpcov8Jped10hRugqO3nq4WGUNEEhSXqs=; b=B3j5GIgrc1ysrlANR6D476TGo0GNvTFgfe4T8ZW7UOu/Mh3I9R5zCG4QQJLxJqRD32 jnCeKpXFJgT/7nN0r3YsCH56fZAIRfluZRNWM0/4oTMPLY1ba8CIp1ifvUWQHCrKIv+c 2hMf+u1L3M8PE9druSpo/2U2SBrN6GG7YWJbZ0izebKcIegndhcsTxKpGR2T9rVFFpJ7 ud1cD5WAJ2UBSl4XC+/YHD2lywZMHimIAYiK7YLTGjcnioK61gJfmDPHaEUvGdi2VReL c0IQHhIrJXd4Nd5yU747oBrvQWcFMW+U/NzWVlSlFMWl33cjRJIV4Qpp5urHeC89VGZh iW9w== X-Gm-Message-State: AOPr4FUeS09O4MMA/i+a8hBL9H3T74Sw3S2MS6PBB6ocywvjOFQgRdPIhjXRj1Rv7BioIFkd8klal1AdywwwoQ== X-Received: by 10.28.165.209 with SMTP id o200mr12397000wme.61.1463931128025; Sun, 22 May 2016 08:32:08 -0700 (PDT) In-Reply-To: <5741cde9$0$1587$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <573EC62F.4090401@lucidity.plus.com> <573f9322$0$1616$c3e8da3$5496439d@news.astraweb.com> <5741cde9$0$1587$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:108945 On Mon, May 23, 2016 at 1:19 AM, Steven D'Aprano wrote: > Okay, now I'm confused. How is 1/2 returning 0.5 the language not doing what > you've told it to do? That isn't the problem. With binary floats, 1/2 can be perfectly represented, so you have no trouble anywhere. The problem comes when you then try 1/5. What do you get? 3602879701896397/18014398509481984. Python shows that as 0.2. Then you do some more arithmetic, and the veil is pierced, and you discover that 1/5 doesn't actually return 0.2, but just something really really close to it - which it tells you is 0.2. I'm not saying that having 1/5 return 0 is better, but I'd like a broad acceptance that 0.2 is imperfect - that, in fact, *every* option is imperfect. ChrisA