tuple question

Justin Sheehy dworkin at ccs.neu.edu
Wed Jun 28 18:56:58 EDT 2000


etoffi <etoffi at softhome.net> writes:

> but what is a tuple and why is it used (as opposed to an array, etc).

It is a simple, immutable sequence.  Use it is situations where you
could use a list, but will never modify the contents of that list
and/or require that nothing else do so either.

This has at least two obvious initial uses:

- dictionary keys  
  (must be immutable)

- parameter passing  
  (it's nice to know that a function won't mangle what is passed to
   them as parameters, unless that's what you really wanted)

There are many other good places to use tuples, but that should give
you enough of an idea.

-Justin

 





More information about the Python-list mailing list