On Friday 31 July 2009 19:49:04 Raymond Hettinger wrote: > On Jul 20, 9:27 am, Phillip B Oldham <phillip.old...@gmail.com> wrote: > > Specifically the "differences" between lists and tuples have us > > confused and have caused many "discussions" in the office. We > > understand that lists are mutable and tuples are not, but we're a > > little lost as to why the two were kept separate from the start. They > > both perform a very similar job as far as we can tell. > > The underlying C code for the two is substantially the same. In terms > of code, tuples are in effect just immutable lists that have the > added > feature of being hashable (and therefore usable as dictionary keys or > elements of sets). > > Beyond the mutable/hashable distinction, there is an important > philosophical distinction articulated by Guido. He deems tuples > to be useful for struct like groupings of non-homogenous fields > and lists to be useful for sequences of homogenous data suitable > for looping. > > While nothing in the list/tuple code requires you to make that > distinction, > it is important because that philosophy pervades the language. If you > follow Guido's direction, you'll find that the various parts of the > language fit together better. Do otherwise and you'll be going > against > the grain.
I might be wrong, but I get the impression that many people don't indeed "get it" and use tuples as static arrays and lists when the array needs to be dynamically resized. This is certainly how I use them as well. This would tend to show that Guido's notion here was not particularly intuitive. Cheers, Emm -- http://mail.python.org/mailman/listinfo/python-list