Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'differently': 0.07; 'element': 0.07; 'elements.': 0.07; 'modified': 0.07; 'augmented': 0.09; 'indicates': 0.09; '(1,': 0.16; 'assignments': 0.16; 'assignments,': 0.16; 'elements,': 0.16; 'gonna': 0.16; 'guessing': 0.16; 'tup': 0.16; 'tuple': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'otherwise,': 0.22; 'error': 0.23; 'header:In- Reply-To:1': 0.27; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'changed.': 0.31; 'lists': 0.32; 'this.': 0.32; 'probably': 0.32; 'not.': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'wrong': 0.37; 'list': 0.37; 'list.': 0.37; 'expected': 0.38; 'lists.': 0.38; 'work?': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'matter': 0.61; "you're": 0.61; 'happen': 0.63; 'taking': 0.65; 'mar': 0.68; 'fact,': 0.69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=SPyo0Ay/5MdEaQXnZGIDsR5Eux2rlfuv7JaFgGr76lE=; b=b3KqNx5yze+JqwH3IlvqiVbuBntfbVCnDUGMdG4C+lma1gWCArK2LJ+SxNaWMMfZmt cWVjFeRZzZ666emm9Oj4vMfrKbDCa6wBE0sOSQ9aXSJ9DVwTJTJqqAqWdN+77DF2TTB6 TTANwzjVLfktiS9Gh5DDpc/hAz64H4nAeYUGRKKXt4qBr6MFba5iNqsvnoecrWJThkAe cWYTq3dbP/WDVtZic5e+n3MHuHfkNnMz44CmZcSF+MEnSMqiI0Pmss+zzlWqUL9nHy68 X4fqKCRCeSOEi1y6e4k77ZWJGNo2AFMjrdgAOpQwkCMP5Oi6wdqL1QzMiSCBEYKo4eEs 9nGg== X-Received: by 10.68.226.70 with SMTP id rq6mr13938648pbc.107.1393763596876; Sun, 02 Mar 2014 04:33:16 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <059a3d10-453a-40fd-99f9-33ceb8ecabf7@googlegroups.com> <889d371a-c8e3-4d6b-8ba4-d3df61f29b0d@googlegroups.com> From: Ian Kelly Date: Sun, 2 Mar 2014 05:32:35 -0700 Subject: Re: Tuples and immutability To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393763606 news.xs4all.nl 2901 [2001:888:2000:d::a6]:41861 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67432 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? tup = (1, 2, 3) tup[1] += 42 I'm guessing probably not. So I have a hard time understanding why it should be expected to work any differently when the tuple element happens to be a list. The fact that the list is actually modified I think is a distraction from the main point: the error indicates that something illegal happened, not that nothing has changed. Assignments just are not allowed on tuple elements, and it doesn't matter what type they happen to be.