SV: [Tutor] Why use tuples?

Danny Kohn danny.kohn@systematik.se
Thu, 20 Sep 2001 19:54:29 +0200


| -----Ursprungligt meddelande-----
| Fr=E5n: Simon Brunning [mailto:SBrunning@trisystems.co.uk]
| Skickat: den 20 september 2001 11:27

| > From:	Danny Kohn [SMTP:danny.kohn@systematik.se]
| > What I understand about the difference in functionality between=20
| lists and
| > tuples is that tuples are restricted lists. But what why would I =
want to
| > use tuples? What is the benifit?
| =20
| See <http://www.python.org/cgi-bin/faqw.py?req=3Dall#6.15> on the FAQ.
|=20
| What this *doesn't* seem to mention is that you can use an immutable =
tuple
| as the key of a dictionary, whereas you cannot use a mutable list.

Ok. But then again I can not use a tuple as an index which would have =
been natural for me to be able to with a datatype of this nature. So =
does the statement

if col[ColType] =3D=3D IU32:

where ColType is a tuple does not work. It is counter intuitive but I =
guess I have to get used to not using tuples.

Thanks anyhow.

/Danny