Phillip B Oldham <phillip.old...@gmail.com> writes: > On Jul 20, 6:08 pm, Duncan Booth <duncan.bo...@invalid.invalid> wrote: >> The main reason why you need both lists and tuples is that because a tuple >> of immutable objects is itself immutable you can use it as a dictionary >> key. > > Really? That sounds interesting, although I can't think of any real- > world cases where you'd use something like that.
An application visiting files on a filesystem recursively needs a dictionary or set keyed by (st_dev, st_ino) to make sure it doesn't visit the same file twice. Memoization implementation (of a cache for results of function application) might need to use a dictionary to map function arguments, a tuple, to the function result. -- http://mail.python.org/mailman/listinfo/python-list