Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Random832 Newsgroups: comp.lang.python Subject: Re: for / while else doesn't make sense Date: Sun, 22 May 2016 13:25:24 -0400 Lines: 38 Message-ID: References: <573EC62F.4090401@lucidity.plus.com> <573f9322$0$1616$c3e8da3$5496439d@news.astraweb.com> <87d1oe2l7z.fsf@elektro.pacujo.net> <1463937924.1827012.615232721.2982AD4D@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de DWMOVxz/w9+3Ijkm3C2YVggFzf6pWG+/sYUGm+vsEXHg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'float': 0.05; '22,': 0.09; 'python:': 0.09; 'received:internal': 0.09; 'subject:while': 0.09; 'python': 0.10; 'value.': 0.15; '$1)': 0.16; 'integer.': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'subject:make': 0.16; 'wrote:': 0.16; "shouldn't": 0.18; 'language': 0.19; '>>>': 0.20; 'fraction': 0.22; 'header:In-Reply- To:1': 0.24; 'appear': 0.26; '(which': 0.26; 'least': 0.27; 'values': 0.28; 'behaviour': 0.29; 'sensible': 0.29; 'types.': 0.29; 'yields': 0.29; 'values.': 0.33; "skip:' 20": 0.34; 'this?': 0.34; 'but': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'detail': 0.38; 'no,': 0.38; 'received:66': 0.38; 'version': 0.38; 'why': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'future': 0.60; 'header :Message-Id:1': 0.61; 'subject: / ': 0.63; 'more': 0.63; 'results': 0.66; 'integrated': 0.72; 'hardly': 0.84; 'nowhere,': 0.84; 'regarded': 0.84; 'subject:else': 0.84; 'subject:sense': 0.84; 'imagine': 0.96 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=v22+5Nh62NEAZp9N0OhM1OdTRfo=; b=nuhPvA RW1JXWQPJReG16mubs7vfPDHsn+HUSOfmJKI/aZtjBb6BQqUIVEVSxME2Mupi1Y8 NxAIbV0fZmP6qE3NrT5oyLUvX2RIHZn8rAAZzX5Shdok+zgCB0JaN1L2ymRoKimb gbMbiTm17KdFf+4jUqr/h/A4rV1XBiK+KC9pA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=v22+5Nh62NEAZp9 N0OhM1OdTRfo=; b=loubTeGC0pc95YGjM1yJivbHRvSsyPH0fvKpSMa1SYEvKju xkHAIxZnQqJR1XwBc6dY/m7TTXZaNLER5jL2ak90ZoGZUnQygtJK4NjZjmH3LiQf f8ES37yLV7ZGSGVtaN3j0+dgKuup4o+UxuGjQ+bZn7wXqtEL0oTXGVL1a59A= X-Sasl-Enc: L5pdb4tOwOQJDVH0loKH1HhFJSYux1gXC5Qt5xKO2u8D 1463937924 X-Mailer: MessagingEngine.com Webmail Interface - ajax-37b57599 In-Reply-To: <87d1oe2l7z.fsf@elektro.pacujo.net> 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: <1463937924.1827012.615232721.2982AD4D@webmail.messagingengine.com> X-Mailman-Original-References: <573EC62F.4090401@lucidity.plus.com> <573f9322$0$1616$c3e8da3$5496439d@news.astraweb.com> <87d1oe2l7z.fsf@elektro.pacujo.net> Xref: csiph.com comp.lang.python:108951 On Sun, May 22, 2016, at 10:58, Marko Rauhamaa wrote: > Scheme has the best of both worlds: > > scheme@(guile-user)> 2/3 > $1 = 2/3 > scheme@(guile-user)> (exact->inexact $1) > $2 = 0.6666666666666666 Why shouldn't Python do this? Imagine some future version of Python: >>> x = 2/3 >>> x (2/3) >>> type(x) # if it's going to be so integrated into the language it's # hardly sensible to keep calling it 'fractions.Fraction' >>> float(x) 0.6666666666666666 On Sun, May 22, 2016, at 11:52, Jon Ribbens wrote: > No, it *adheres* to the principle of least surprise. Floats appearing > out of nowhere is surprising. Python 2's behaviour adhered to the > principle, and Python 3's breaks it. Disregarding for the moment the particular imperfections of the float representation (which would be gone if we used Fraction instead), this is only true if the concrete types of results are regarded as part of the result rather than as an implementation detail for how best to return the requested value. I think it would be entirely reasonable for Fractions to not only appear out of nowhere, but to *disappear* when an operation on them yields a value which is an integer. Values are more important than types. Types are less important than values.