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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assignment': 0.07; 'modified': 0.07; 'result,': 0.07; 'skip:` 10': 0.07; 'integers': 0.09; 'cc:addr:python-list': 0.11; 'wrote': 0.14; '3:27': 0.16; 'defined.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'least.': 0.16; 'nick': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'feb': 0.22; 'handles': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'header :In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'consequence': 0.31; 'fri,': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'being': 0.38; 'called': 0.40; 'actually,': 0.84; 'to:none': 0.92 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 :content-type; bh=+BytqS2vXiHozwUXQUBK/vum++1vzyllZqVSlSevgwU=; b=Rs2b+VZd6By1BJOlwAWRdMRmmYBIHIkoOmZE1cVp9A6X88ULzGhWXmJ50O7sKVaeNM wuANNHVt136UPJbwwzosoZR42D3u0WGE5bJHqKUzcCpVAjyZ+vvT6XQ/a1FKmYIVzbzt SRBkS8TK9xNjvdnvDwTTmyT93kbgGb/5cdEGlQF+vgPWIbyz2R+hgPmAtZU58ZJn2Rr2 bnHaSX17YZE95vW9NjKX+NGhu6nvX5k5HfjmSruDGO1sXlpvigqu4hHVIIYRgrzEpMak +a4G94V9t+k5F3BH1ViENMmV5XoyAqTRMg5YSsT7FYLHbK69v2QZg+qZUPe6scTm45U9 jK9g== MIME-Version: 1.0 X-Received: by 10.68.201.10 with SMTP id jw10mr15759435pbc.25.1393537968192; Thu, 27 Feb 2014 13:52:48 -0800 (PST) In-Reply-To: References: Date: Fri, 28 Feb 2014 08:52:48 +1100 Subject: Re: Tuples and immutability From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393537971 news.xs4all.nl 2971 [2001:888:2000:d::a6]:51188 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67168 On Fri, Feb 28, 2014 at 8:47 AM, Nick Timkovich wrote: > On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico wrote: >> >> On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni >> wrote: >> > But, imho, it's far from being a intuitive result, to say the least. >> >> It's unintuitive, but it's a consequence of the way += is defined. If >> you don't want assignment, don't use assignment :) >> >> ChrisA > > > Where is `.__iadd__()` called outside of `list += X`? If the only > difference from `.extend()` is that it returns `self`, but the list was > already modified anyway, why bother with reassignment? Not everything handles += that way. You can't mutate the integer 5 into 7 because someone had 5 in x and wrote "x += 2". So it has to reassign. Actually, integers just don't define __iadd__, but the principle applies. ChrisA