Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'behave': 0.07; 'python': 0.08; '"hello': 0.09; '>>>>': 0.09; 'either.': 0.09; 'operator,': 0.09; 'substring': 0.09; '"d"': 0.16; '0.3': 0.16; 'constructs': 0.16; 'dictionaries': 0.16; 'did.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'negatives': 0.16; 'set,': 0.16; 'subtract': 0.16; 'subtraction': 0.16; 'then:': 0.16; 'mon,': 0.16; 'wrote:': 0.16; 'language': 0.17; '>>>': 0.18; 'programming': 0.20; "doesn't": 0.22; 'assume': 0.22; 'header:In- Reply-To:1': 0.22; 'work,': 0.23; '0.1': 0.23; 'pm,': 0.24; 'aug': 0.24; 'expect': 0.25; 'message-id:@mail.gmail.com': 0.29; 'objects': 0.32; "isn't": 0.33; "can't": 0.33; 'to:addr:python- list': 0.33; 'fail': 0.34; 'nobody': 0.34; 'quite': 0.34; 'closely': 0.34; 'numbers.': 0.34; 'reference': 0.35; 'languages': 0.37; 'using': 0.37; 'but': 0.37; 'could': 0.38; 'think': 0.38; 'steven': 0.38; 'received:google.com': 0.38; 'subject:: ': 0.39; 'sets': 0.39; 'represent': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.39; "i'd": 0.40; "it's": 0.40; 'more': 0.60; 'removal': 0.64; 'show': 0.67; 'high': 0.67; 'subject:line': 0.73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=gMZzJBgMj/Zv4VzK5lwunoEHe/Y0QLMlsjFgsV2+gfA=; b=d2D1g61FA9G3i5DT/fAuu1qB6ZJOVyNd2KX0YvOjbJuHhUpBzFg6/L77VOqQO3QnbM W6NUQyWYkXJLrnjOzfCnPU5Og2M2bK4gA0lr/W1m9uZF2dhDwuC69VauvRrgiN8XQaf6 QieKnlXY4LLKBiVMpmiJK1XwYoHv/xl3+hF0E= MIME-Version: 1.0 In-Reply-To: <4e492d08$0$30003$c3e8da3$5496439d@news.astraweb.com> References: <1312951356.77394.YahooMailNeo@web121518.mail.ne1.yahoo.com> <1312981104.89312.YahooMailNeo@web121520.mail.ne1.yahoo.com> <1312982377.95657.YahooMailNeo@web121508.mail.ne1.yahoo.com> <87fwl9hr4r.fsf@benfinney.id.au> <4e43cb2a$0$29986$c3e8da3$5496439d@news.astraweb.com> <74c2421f-28a0-4a8d-bf74-4eebacfb74f1@d7g2000vbv.googlegroups.com> <92b8f192-d7fc-4c60-87ad-71b12652f3a2@k8g2000yqk.googlegroups.com> <4e492d08$0$30003$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 15 Aug 2011 15:42:08 +0100 Subject: Re: allow line break at operators From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313419331 news.xs4all.nl 23921 [2001:888:2000:d::a6]:60355 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11462 On Mon, Aug 15, 2011 at 3:28 PM, Steven D'Aprano wrote: > And of course, once you start using floating point numbers, you can't assume > commutativity: > >>>> 0.1 + 0.7 + 0.3 == 0.3 + 0.7 + 0.1 > False > This isn't because programming languages fail to follow mathematics; it's because floating point numbers do not represent real numbers. Python doesn't support substring removal using the subtraction operator, but I'd have to say that floats more closely parallel strings and other high level objects than they do mathematical reals. If Python treated __sub__(str,str) as str.replace(str,"") then: >>> "hello world" + "asdfqwer" - "d" "hello worlasfqwer" >>> "hello world" - "d" + "asdfqwer" "hello worlasdfqwer" Nobody would expect strings to behave mathematically with subtraction, because negatives don't make sense. Even sets don't quite work, although they're closer: >>> set("asdf")-set("test") {'a', 'd', 'f'} There's no way, in a set, to show a negative reference to 't' and 'e'. In theory you could do this with dictionaries or collections.Counter, but subtracting a Counter from a Counter doesn't produce negative numbers either. No, these constructs do not subtract algebraically, and I do not think it would be any improvement to the language if they did. ChrisA