Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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; 'operator': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'yet.': 0.04; 'element': 0.07; 'elements.': 0.07; 'modified': 0.07; 'modify': 0.07; 'modifying': 0.07; 'append': 0.09; 'augmented': 0.09; 'lawrence': 0.09; 'methods,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'though...': 0.09; 'works.': 0.09; 'python': 0.11; 'language.': 0.14; '13:38,': 0.16; 'assignments,': 0.16; 'equation': 0.16; 'gonna': 0.16; 'operation,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'tuple': 0.16; 'tuple.': 0.16; '\xe9crit': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'issue.': 0.22; 'otherwise,': 0.22; 'header:User- Agent:1': 0.23; 'initial': 0.24; '---': 0.24; 'question': 0.24; "i've": 0.25; '(see': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; "i'm": 0.30; 'lists': 0.32; 'this.': 0.32; 'covered': 0.32; 'extend': 0.32; 'worked': 0.33; "i'd": 0.34; 'except': 0.35; 'but': 0.35; 'consistent': 0.36; 'doubt': 0.36; 'shows': 0.36; 'should': 0.36; 'wrong': 0.37; 'so,': 0.37; 'list': 0.37; 'list.': 0.37; 'lists.': 0.38; 'work?': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'previous': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'ian': 0.60; 'free': 0.61; 'viruses': 0.61; "you're": 0.61; 'protection': 0.63; 'our': 0.64; 'taking': 0.65; 'mar': 0.68; 'antivirus': 0.68; 'fact,': 0.69; 'designers': 0.74; 'behavior': 0.77; 'future,': 0.83; '"spam"': 0.84; 'maybe,': 0.84; 'replacements': 0.84; 'mistake': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Tuples and immutability Date: Sun, 02 Mar 2014 14:05:35 +0000 References: <059a3d10-453a-40fd-99f9-33ceb8ecabf7@googlegroups.com> <889d371a-c8e3-4d6b-8ba4-d3df61f29b0d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-78-147-179-76.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: X-Antivirus: avast! (VPS 140301-2, 01/03/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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393769155 news.xs4all.nl 2840 [2001:888:2000:d::a6]:36380 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67439 On 02/03/2014 13:38, Eric Jacoboni wrote: > Le 02/03/2014 13:32, Ian Kelly a écrit : >> On Sat, Mar 1, 2014 at 7:04 PM, Eric Jacoboni wrote: >>> In fact, i think i'm gonna forget += on lists :) >> >> Well, do what you want, but I think you're taking the wrong lesson >> from this. Don't forget about using += on lists. Instead, forget >> about using assignments, augmented or otherwise, on tuple elements. >> Would you expect this to work? > > Well, the thing about += on lists that makes me forget it, like i said > in my previous post, is that its behaviour is not consistent with +. The behaviour is consistent except when you try to modify a tuple. > > Don't get me wrong: i don't expect that modifying a tuple element works. > That's exactly my point: my initial question was, why it "half works : > it should not work at all". I was thinking that += on lists worked like > update() or extend() : modifying lists in place... It was my mistake I'd like to see you get update to work on a list. This shows how confused you are over this issue. > > So, yes, i still don't get the point using a += operation, which is not > even consistent with the + operation (see my exemple on "spam" in my > previous post). The + operator to return the modified list and the > update() or extend() methods to do in place replacements are well enough > for my present needs. Maybe, in the future, i will find a use case of += > for lists which is not covered by others methods, though... Who knows? I > don't doubt that Python designers have made this choice and this > behavior for a good reason: i've just not get it yet. > All of this comes about because of the known issue with tuples. Take them out of the equation and the behaviour of =, +=, extend and append is consistent. -- 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