Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69761
| References | <89df32f9-c8ae-4b7b-bfc4-01c574aabcae@googlegroups.com> <53410185.6050304@islandtraining.com> <CABicbJK=Fw+m9pjgm9Ng=h=if38YL6uo4ibgiA43S6ohV9XUKg@mail.gmail.com> <CAPTjJmqkeWO8stSDGECcvyU2217uDeZgX9gtVC+0=58195sj=A@mail.gmail.com> |
|---|---|
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Date | 2014-04-06 04:01 -0700 |
| Subject | Re: Mutable objects inside tuples - good or bad? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8947.1396782118.18130.python-list@python.org> (permalink) |
On Sun, Apr 6, 2014 at 1:25 AM, Chris Angelico <rosuav@gmail.com> wrote: > On Sun, Apr 6, 2014 at 5:55 PM, Devin Jeanpierre <jeanpierreda@gmail.com> 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
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