Path: csiph.com!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: Tue, 24 May 2016 04:14:37 +1000 Lines: 36 Message-ID: References: <5741cde9$0$1587$c3e8da3$5496439d@news.astraweb.com> <57422e03$0$1596$c3e8da3$5496439d@news.astraweb.com> <85r3ct9zt2.fsf@benfinney.id.au> <5742bacb$0$1526$c3e8da3$5496439d@news.astraweb.com> <87zirgrgol.fsf@bsb.me.uk> <574336f5$0$1600$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de jPozSwy4m6tGWmoi4kT3lQQyoUXVSKzaMeQHjP2+bbDg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'bug.': 0.07; 'counting': 0.07; 'cc:addr:python-list': 0.09; 'integers': 0.09; 'subject:while': 0.09; 'subtle': 0.09; 'bug': 0.10; 'python': 0.10; "(it's": 0.16; '2016': 0.16; '24,': 0.16; 'advocating': 0.16; 'calendar.': 0.16; 'decimal.': 0.16; 'expects': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gotcha.': 0.16; 'integers,': 0.16; 'nerds': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:make': 0.16; 'with;': 0.16; 'wrote:': 0.16; 'integer': 0.18; 'odd': 0.18; '>>>': 0.20; 'people,': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'int,': 0.22; 'am,': 0.23; 'header:In- Reply-To:1': 0.24; "i've": 0.25; "doesn't": 0.26; 'chris': 0.26; 'earlier': 0.27; 'bugs': 0.27; 'least': 0.27; 'message- id:@mail.gmail.com': 0.27; '[2]': 0.27; 'restrict': 0.27; 'another.': 0.29; 'division': 0.29; 'probably': 0.31; '[1]': 0.32; 'changed': 0.33; "d'aprano": 0.33; 'int': 0.33; 'steven': 0.33; 'tue,': 0.34; 'gives': 0.35; 'received:google.com': 0.35; 'options:': 0.35; 'received:74.125.82': 0.35; "isn't": 0.35; 'but': 0.36; 'too': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'being': 0.37; 'things': 0.38; 'busy': 0.38; 'why': 0.39; "didn't": 0.39; 'easy': 0.60; 'making': 0.62; 'subject: / ': 0.63; 'more': 0.63; 'deeply': 0.64; "they're": 0.66; 'prime': 0.72; 'obvious': 0.76; '*every': 0.84; 'chrisa': 0.84; 'float,': 0.84; 'proving': 0.84; 'received:74.125.82.41': 0.84; 'subject:else': 0.84; 'subject:sense': 0.84; 'whatsoever.': 0.84; 'to:none': 0.91; 'fibonacci': 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=aNSJ+En+ni6vz6IPNi8NjZfNRWIJWfFS/f+HKskI4pE=; b=DiCHYePnLKiwh6rATb8TgTYKaTNoNbujb+WeBb/81EjBLpSsRe9zRohBN1w2Qfh0Yj xLvuNDqkkrJYrkgSCehbxH2SJxbucagYX68pALRxLNWf9+1NtgaKhDM9YtyLvrSI7OBK SqAp2vEDEvrboAWeTTPFiN9sbqX4vxaCyJPPmf2RZh5EvF5gqrb15Zu2iErlZNEg0SfY WErn0xEA/p4zYZ9l2Imy+Cy21Olm21O2yvPyYOqCnWUgpTlQkWj0yYFo+Ff8ypbKx14D 2S7UFRhddg4fvPZKdBs1D8uoVFo7SokWzpInp+qsdfiDWtx+/SMVcyFeZZMB2xxnOmKf ct8w== 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=aNSJ+En+ni6vz6IPNi8NjZfNRWIJWfFS/f+HKskI4pE=; b=dVHOPzFjNYuJz5ZLjp4RJjR2Mlac5Xqx92VLYB1E+oGL21maFks/EG0kxKfT8SnQH/ hLf7YP3IBu4Alf2/kGxp9MmSjfabPAN7VFOEdBp9ET3P791R/EOZA6qElywaXPnJmFpV md+arx68JPbAH3134RweldQqCk45Mz6I+yISmYY5EoSbpnHJ5KOsJwoAaEEWVbtjCPrN uYxugPwwWOzr4ddIzxT7D4TtWaSvLqnPmXEHQmXXjYKdhBUZOmueN7e/7l9kLPizHrIY J0Gj6b5DqAmzXn4xZ/mgz49QQ4uViltNqRI06NDaNgtbDXQI+0u1PlDzbRcej168V54Z y+YA== X-Gm-Message-State: ALyK8tKAtHzdLT0UA3pVY/NTm6dxzow3GoGZQ0BwntkOwlSfhBgoFvsSMejIxA+mr7UYHa7V4dXVSOn3uEXxAw== X-Received: by 10.194.86.129 with SMTP id p1mr150020wjz.117.1464027277665; Mon, 23 May 2016 11:14:37 -0700 (PDT) In-Reply-To: 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: <5741cde9$0$1587$c3e8da3$5496439d@news.astraweb.com> <57422e03$0$1596$c3e8da3$5496439d@news.astraweb.com> <85r3ct9zt2.fsf@benfinney.id.au> <5742bacb$0$1526$c3e8da3$5496439d@news.astraweb.com> <87zirgrgol.fsf@bsb.me.uk> <574336f5$0$1600$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:109018 On Tue, May 24, 2016 at 3:57 AM, Jon Ribbens wrote: > On 2016-05-23, Chris Angelico wrote: >> On Tue, May 24, 2016 at 3:09 AM, Jon Ribbens >> wrote: >>> On 2016-05-23, Steven D'Aprano wrote: >>>> But one thing is certain: very few people, Jon Ribbens being one of them, >>>> expects 1/3 to return 0. And that is why Python changed the meaning of >>>> the / operator: because using it for integer division was deeply unpopular >>>> and a bug magnet. >>> >>> Making it return floats is also a bug magnet, just for more subtle >>> bugs that are harder to diagnose. >> >> See my earlier post. There are four broadly-viable options: int, >> float, Fraction, Decimal. *Every one of them* is a bug magnet in one >> way or another. Which kind of bug would you like? > > The simplest one - isn't that obvious from what I've already said? Gotcha. You're advocating Fraction, which has no bugs whatsoever. Of course, it doesn't give you any more numbers than int gives you [1], but at least it doesn't restrict you to crazy things like only fifty-three significant digits [2] in its binary representation. And it's really easy to work with; performance is predictable (it's just two integers, and we know that the performance of integers is predictable), and they're easy to eyeball. ChrisA [1] Rationals and integers are both "countably infinite" - there are as many of each as there are counting numbers, odd numbers, prime numbers, squares, Fibonacci numbers, and dates in the Julian calendar. And dates that nerds didn't get because they were too busy proving which things are countably infinite and which aren't. [2] The number of the Love Bug. This is probably significant.