list vs tuple
Mark Pilgrim
f8dy at yahoo.com
Wed Mar 28 13:18:00 EST 2001
"Aahz Maruch" <aahz at panix.com> wrote in message
news:99stcb$483$1 at panix6.panix.com...
> In article <hGlw6.782$p5.3210 at news1.rivrw1.nsw.optushome.com.au>,
> deadmeat <root@[127.0.0.1]> wrote:
> >
> >Whats the practical difference between a list[] and a tuple() ?
>
> As someone said, tuples are immutable. This leads to useful
> functionality, such as being able to easily use tuples as keys in
> dictionaries (ditto strings).
It was my understanding that only tuples containing immutable objects could
be used as dictionary keys. For instance, (1,2,3) can be, and ("a","b","c")
can be, but ([1,2,3], ["a","b","c"]) can not, because the underlying objects
could mutate and cause problems. (Wow, that sounds like a bad sci-fi
movie.) Is this true?
-M
You're smart; why haven't you learned Python yet?
http://diveintopython.org/
More information about the Python-list
mailing list