On Wednesday 22 July 2009 16:36:51 Inky 788 wrote: > On Jul 22, 2:36 am, Hendrik van Rooyen <hend...@microcorp.co.za> > > wrote:
> > The good reason is the immutability, which lets you use > > a tuple as a dict key. > > Thanks for the reply Hendrik (and Steven (other reply)). Perhaps I'm > just not sophisticated enough, but I've never wanted to use a list/ > tuple as a dict key. This sounds like obscure usage, and a bit > contrived as a reason for having *both* lists and tuples. Steven showed why you cannot have a mutable thing as a key in a dict. if you think it is contrived, then please consider how you would keep track of say the colour of a pixel on a screen at position (x,y) - this is about the simplest "natural" tuple format and example. There are other equally valid examples, as has been pointed out. (may have been in another thread - am a bit confused about that right now) - Hendrik -- http://mail.python.org/mailman/listinfo/python-list