Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1a.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.066 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'interpreter': 0.05; 'whole.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'at.': 0.16; 'hashable': 0.16; 'mutable': 0.16; 'unhashable': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'example': 0.22; 'programming': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'agreed.': 0.31; 'context.': 0.31; 'ok.': 0.31; 'tuples': 0.31; 'another': 0.32; 'totally': 0.33; 'could': 0.34; 'common': 0.35; 'no,': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'useful': 0.36; 'subject:?': 0.36; 'easily': 0.37; 'sometimes': 0.38; 'pm,': 0.38; 'even': 0.60; 'break': 0.61; 'entire': 0.61; "you're": 0.61; 'such': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'legal': 0.71; 'behavior': 0.77; 'compare:': 0.84; 'fragment': 0.84; 'subject:good': 0.84 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=7NuCtbj35wYjTI45STdXj8x1UVG0z1PAqUIsdjOA8dI=; b=xEeCOxlRnFHB5Xdz9WLmDTHJTeLyDelSgW3ehpkTK/XKcBv0ydrtphhZHU19G+PubM A1uQon4Py49Pe33ZN2CJU5rgYpPpZzk65ZO53dCYzbpE+cXRaS0Kah7Z6+JGi/SqoUTk D7s8vFN7VI5e1BZgXPq27JIUOYGbKbLmitiOS9ntol4p81d07MVSueciPY0z7JW1dRPY ZwvLbBGQahLxqKUm0uO/CUO2784HlrmVKzld9A6t74Dcjgw3gFOu8FQUUtmVZVI8XC0z 3vGLhGJXfl77r/VkPWcfgS52Dnv00vhxfQPLVOLTNXK8ABbBrIW9UWd5z55LDgmRKjLf DBOw== X-Received: by 10.140.91.105 with SMTP id y96mr25141193qgd.3.1396782110260; Sun, 06 Apr 2014 04:01:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <89df32f9-c8ae-4b7b-bfc4-01c574aabcae@googlegroups.com> <53410185.6050304@islandtraining.com> From: Devin Jeanpierre Date: Sun, 6 Apr 2014 04:01:10 -0700 Subject: Re: Mutable objects inside tuples - good or bad? To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: "comp.lang.python" 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396782118 news.xs4all.nl 2869 [2001:888:2000:d::a6]:43235 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69761 On Sun, Apr 6, 2014 at 1:25 AM, Chris Angelico wrote: > On Sun, Apr 6, 2014 at 5:55 PM, Devin Jeanpierre wrote: >> Agreed. Putting mutable objects inside tuples is common and totally OK. > > There are many programming habits that can cause problems, even though > they won't break Python and are legal code. :) Yes, but this isn't one of them. >> 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 > > What you're looking at here is hashability, not mutability. Compare: No, that is not what I am looking at. There are hashable objects with the property I described, and unhashable objects without it. My point in that example was that sometimes it is more useful to talk about entire objects and their behavior as a whole. Calling the object "immutable" when it has mutable state is misleading in this context. -- Devin