Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python.': 0.02; 'objects,': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'python': 0.11; '3],': 0.16; 'immutable,': 0.16; 'objects.': 0.16; 'tuple': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'feb': 0.22; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'received:(smtp server)': 0.26; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'comments': 0.31; '>>>>': 0.31; 'consisting': 0.31; 'gary': 0.31; 'linux': 0.33; 'but': 0.35; 'subject:?': 0.36; 'two': 0.37; 'problems': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'break': 0.61; 'no.': 0.61; 'john': 0.61; 'kind': 0.63; 'more': 0.64; 'legal': 0.71; '2014,': 0.84; 'subject:good': 0.84; 'problems?': 0.91 X-Virus-Scanned: OK Date: Sun, 06 Apr 2014 00:25:57 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Mutable objects inside tuples - good or bad? References: <89df32f9-c8ae-4b7b-bfc4-01c574aabcae@googlegroups.com> In-Reply-To: <89df32f9-c8ae-4b7b-bfc4-01c574aabcae@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396769507 news.xs4all.nl 2970 [2001:888:2000:d::a6]:46726 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69747 On 04/05/2014 11:53 PM, John Ladasky wrote: > I find this programming pattern to be useful... but can it cause problems? No. What kind of problems are you considering? It won't break Python. It's perfectly legal code. The tuple c is still immutable, consisting of two specific objects, and (as always) without regard to the specifics or contents of those two objects. Gary Herron > > Python 3.3.2+ (default, Feb 28 2014, 00:52:16) > [GCC 4.8.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> a = [1,2,3] >>>> b = [4,5,6] >>>> c = (a,b) >>>> c > ([1, 2, 3], [4, 5, 6]) >>>> c[0][0] = 0 >>>> c > ([0, 2, 3], [4, 5, 6]) > > Comments appreciated.