Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; '"""': 0.07; 'assignment': 0.07; 'binary': 0.07; 'modified': 0.07; '[1,': 0.09; 'assigning': 0.09; 'augmented': 0.09; 'lawrence': 0.09; 'performs': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'satisfy': 0.09; 'similar,': 0.09; 'target,': 0.09; 'bug': 0.12; 'language.': 0.14; '"an': 0.16; '3],': 0.16; 'conformance': 0.16; 'effect.': 0.16; 'in-place,': 0.16; 'once.': 0.16; 'ought': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rewritten': 0.16; 'wording': 0.16; 'attach': 0.16; 'language': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'possible,': 0.19; 'manual': 0.22; 'creating': 0.23; 'header :User-Agent:1': 0.23; 'instead.': 0.24; '---': 0.24; 'references': 0.26; 'suggested': 0.26; 'tracker': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'patch': 0.29; 'raise': 0.29; 'doc': 0.31; 'actual': 0.34; 'equal': 0.35; 'but': 0.35; 'there': 0.35; 'two': 0.37; 'version,': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'rather': 0.38; 'quote': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'either': 0.39; 'received:org': 0.40; 'expression': 0.60; 'free': 0.61; 'new': 0.61; 'viruses': 0.61; 'skip:* 10': 0.61; 'protection': 0.63; 'skip:n 10': 0.64; 'our': 0.64; 'email addr:python.org.': 0.66; 'here': 0.66; '>from': 0.68; 'antivirus': 0.68; 'link:': 0.72; 'behavior': 0.77; 'comparable': 0.84; 'object:': 0.84; 'significance': 0.84; 'yourself,': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: TypeError expected in an augmented assignment Date: Thu, 03 Jul 2014 13:43:23 +0100 References: <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> <6ed679b1-c6e1-408e-8167-476b169fa2eb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-18-5-57.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <6ed679b1-c6e1-408e-8167-476b169fa2eb@googlegroups.com> X-Antivirus: avast! (VPS 140703-0, 03/07/2014), Outbound message X-Antivirus-Status: Clean 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: 78 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1404391406 news.xs4all.nl 2883 [2001:888:2000:d::a6]:34645 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73899 On 03/07/2014 10:35, candide wrote: > > >> >From that link: >> >> >> >> """ >> >> An augmented assignment expression like x += 1 can be rewritten as x = >> >> x + 1 to achieve a similar, but not exactly equal effect. In the >> >> augmented version, x is only evaluated once. Also, when possible, the >> >> actual operation is performed in-place, meaning that rather than >> >> creating a new object and assigning that to the target, the old object >> >> is modified instead. >> >> """ >> >> >> >> The significance here is that the augmented assignment may not >> >> necessarily be at all comparable to the non-augmented version, but >> >> ought to have *approximately* the same *intention*. > > > This is not my reading. > > > > >> >> of situations where the two will differ, eg when there are multiple >> >> references to the same object: >> >> >> >>>>> a = b = [1,2] >> >>>>> a += [3] >> >>>>> a,b >> >> ([1, 2, 3], [1, 2, 3]) >> >>>>> a = a + [4] >> >>>>> a,b >> >> ([1, 2, 3, 4], [1, 2, 3]) >> >> > > OK but this behavior is in conformance with the Reference Manual (cf. your quote above : "when possible, the actual operation is performed in-place"). This is not my point because the doc explictly claims that "an augmented assignment [...] performs the binary operation specific to the type of assignment on the two operands". > To get the wording changed to satisfy yourself, either raise an issue on the bug tracker at bugs.python.org and attach a patch file, or send an email with suggested wording to docs@python.org. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com