Help understanding the decisions *behind* python?

Duncan Booth duncan.booth at invalid.invalid
Mon Jul 20 21:54:02 CEST 2009


Phillip B Oldham <phillip.oldham at gmail.com> wrote:

> On Jul 20, 6:08 pm, Duncan Booth <duncan.bo... at 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.
> 

How about a multi-dimensional sparse array?

>>> d = {}
>>> d[1,2] = 'a'
>>> d[5,7] = 'b'




More information about the Python-list mailing list