Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.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.068 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'considered,': 0.09; 'converted': 0.09; 'immutable': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'tuple': 0.16; 'sat,': 0.16; 'all.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'error': 0.23; 'integer': 0.24; 'fine': 0.24; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'tuples': 0.31; 'lists': 0.32; "we're": 0.32; 'quite': 0.32; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'words,': 0.36; 'should': 0.36; 'changing': 0.37; 'half': 0.37; 'two': 0.37; 'list': 0.37; 'list.': 0.37; 'list,': 0.38; 'changed': 0.39; 'even': 0.60; 'skip:u 10': 0.60; 'matter': 0.61; "you're": 0.61; 'first': 0.61; 'different': 0.65; 'talking': 0.65; 'within': 0.65; 'mar': 0.68; 'containing': 0.69; 'do:': 0.91; '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:content-transfer-encoding; bh=MOCAh3cSb/kLPnKgOuh/vAyKcYOapIZtLXJRfTyMP+s=; b=nNLwmh8N5AFAHsDjLDMqbOYtYO2+S3pnPodBZtX9TBn8kJIt/XtW4B+ywYLvjWjolq U/L7Gvn9NQnyaiVlya9ibfTmuzNayXg1VkXjfRIH8fDkjGpiL6TqpiqxN3p39of2zoR4 ebjcpC7M7IaaTTjwK2TLnwj96VzgKPud/D5rDXArP+gu/TQE7mfJx8dtq7rQHyfZXbXY oN6N84Pnsug62eI+h6DzrQOKNtpUk3YGDrgB/nuoiL0OTHsMVXHvQswH3V5vM7YM+48X ycpaE3GIjD+oboK4IGtdzbdf97s30PW6kAmTNs3P+zYolHulsBOPF82CHNJXZZvOPFEl d3qg== MIME-Version: 1.0 X-Received: by 10.66.118.71 with SMTP id kk7mr7057872pab.14.1393637945111; Fri, 28 Feb 2014 17:39:05 -0800 (PST) In-Reply-To: <059a3d10-453a-40fd-99f9-33ceb8ecabf7@googlegroups.com> References: <059a3d10-453a-40fd-99f9-33ceb8ecabf7@googlegroups.com> Date: Sat, 1 Mar 2014 12:39:05 +1100 Subject: Re: Tuples and immutability From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393637948 news.xs4all.nl 2872 [2001:888:2000:d::a6]:49192 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67277 On Sat, Mar 1, 2014 at 11:22 AM, Mark H. Harris wro= te: > lists within a tuple should be converted to tuples. If you want a tupl= e to hold a list, make it a list in the first place. Tuples should not be= changed... and as you point out... half changing a tuple is not a good con= dition if there is an exception... > A tuple is perfectly fine containing a list. If you want a tuple to be "recursively immutable", then you're talking about hashability, and *then* yes, you need to convert everything into tuples - but a tuple is not just an immutable list. The two are quite different in pupose. > I really think this is a bug; honestly. IMHO it should be an error to us= e +=3D with an immutable type and that means not at all. In other words,= the list should not even be considered, because we're talking about chang= ing a tuple... which should not be changed (nor should its members be chang= ed). > Definitely not! Incrementing an integer with +=3D is a perfectly normal thing to do: x =3D 5 x +=3D 1 It's just a matter of knowing the language and understanding what's going o= n. ChrisA