Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69749
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jeanpierreda@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'python.': 0.02; 'interpreter': 0.05; 'contexts': 0.09; 'objects,': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '3],': 0.16; 'immutable,': 0.16; 'mutability': 0.16; 'mutable': 0.16; 'objects.': 0.16; 'tuple': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'feb': 0.22; '>>>': 0.22; 'programming': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'comments': 0.31; 'agreed.': 0.31; 'consisting': 0.31; 'gary': 0.31; 'ok.': 0.31; 'tuples': 0.31; 'another': 0.32; 'linux': 0.33; 'url:python': 0.33; 'totally': 0.33; 'could': 0.34; 'common': 0.35; 'definition': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'two': 0.37; 'easily': 0.37; 'problems': 0.38; 'pm,': 0.38; 'url:mail': 0.40; 'break': 0.61; 'no.': 0.61; 'john': 0.61; "you'll": 0.62; 'kind': 0.63; 'such': 0.63; 'choose': 0.64; 'more': 0.64; 'useful.': 0.68; 'legal': 0.71; '2014,': 0.84; 'fragment': 0.84; 'subject:good': 0.84; 'problems?': 0.91 |
| 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 :cc:content-type; bh=qHRGXnlcysYtqEGBCEXfC1w3gFTtQKciZWtZH9w7BxA=; b=d9sv1csovPX0uyRIeEej8HNCTYnTxUxi0RRkKbvswuevXErtlu6kGNLvZLFk6PCeEx KndugoHYg2qYHA81aZdzkouO0xcDyO/7O+BCnAqYpcA+/x3YMKTB83LSxMOv1sQVq6th +381EL2vOMdNqHkNzTh2hs7uCQjHFLh8VaBkfR09zC+WAMk4puN81JuowaBnjeOhtTeD A/bEgI07l9bzTxfhNf5gd7E4DWd51WkzsM/LHCjaTx/VMWF01opNQf6MT+sS1/Z8yAS/ OscaUgWBrbesZB6KCiXToE7VSu6opEXNeyCO7gBoAi6uoTAGwjpoMv9dP/bboAEyweum gblA== |
| X-Received | by 10.140.23.148 with SMTP id 20mr647700qgp.89.1396770998920; Sun, 06 Apr 2014 00:56:38 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <53410185.6050304@islandtraining.com> |
| References | <89df32f9-c8ae-4b7b-bfc4-01c574aabcae@googlegroups.com> <53410185.6050304@islandtraining.com> |
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | Sun, 6 Apr 2014 00:55:58 -0700 |
| Subject | Re: Mutable objects inside tuples - good or bad? |
| To | Gary Herron <gary.herron@islandtraining.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "comp.lang.python" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8940.1396771007.18130.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1396771007 news.xs4all.nl 2926 [2001:888:2000:d::a6]:52429 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:69749 |
Show key headers only | View raw
On Sun, Apr 6, 2014 at 12:25 AM, Gary Herron <gary.herron@islandtraining.com> wrote: > 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. Agreed. Putting mutable objects inside tuples is common and totally OK. > 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. You can choose to define mutability that way, but in many contexts you'll find that definition not very useful. c is such that you could have another variable d, where the following interpreter session fragment is easily possible: >>> c == d True >>> foo(c) >>> c == d False -- Devin >> 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. > > > -- > https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Mutable objects inside tuples - good or bad? John Ladasky <john_ladasky@sbcglobal.net> - 2014-04-05 23:53 -0700
Re: Mutable objects inside tuples - good or bad? Gary Herron <gary.herron@islandtraining.com> - 2014-04-06 00:25 -0700
Re: Mutable objects inside tuples - good or bad? Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-04-06 00:55 -0700
Re: Mutable objects inside tuples - good or bad? Rustom Mody <rustompmody@gmail.com> - 2014-04-06 08:07 -0700
Re: Mutable objects inside tuples - good or bad? Chris Angelico <rosuav@gmail.com> - 2014-04-06 18:25 +1000
Re: Mutable objects inside tuples - good or bad? Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-04-06 04:01 -0700
Re: Mutable objects inside tuples - good or bad? Paul Kölle <paul@subsignal.org> - 2014-04-07 17:26 +0200
Re: Mutable objects inside tuples - good or bad? Chris Angelico <rosuav@gmail.com> - 2014-04-08 01:44 +1000
Re: Mutable objects inside tuples - good or bad? Paul Kölle <paul@subsignal.org> - 2014-04-07 21:46 +0200
Re: Mutable objects inside tuples - good or bad? Chris Angelico <rosuav@gmail.com> - 2014-04-08 08:47 +1000
Re: Mutable objects inside tuples - good or bad? Terry Reedy <tjreedy@udel.edu> - 2014-04-07 20:16 -0400
Re: Mutable objects inside tuples - good or bad? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-08 02:53 +0000
csiph-web