List vs tuples

Andrei project5 at redrival.net
Thu Apr 8 16:59:08 EDT 2004


Mitja wrote on Thu, 8 Apr 2004 18:47:07 +0200:

> A neewbie's question here, probably discussed before:
> what's the purpose of having both lists AND tuples?
> At the first (and second and third, to be honest) glance lists are just
> tuples with extended functionality, so why have tuples around?

You can use tuples as keys in a dictionary, but you can't use lists for
that purpose (because they're mutable).

> I've been working with Python for a few months now but haven't yet come
> across a problem that would really require tuples.

That's possible. Lists offer many more facilities than tuples (mainly due
to them being mutable), so it's easier to just use a list (even if a tuple
could do the job).

-- 
Yours,

Andrei

=====
Real contact info (decode with rot13):
cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
gur yvfg, fb gurer'f ab arrq gb PP.



More information about the Python-list mailing list