[Greg Wilson]
4. "Aren't tuples redundant?"
I explained that the const-ness of tuples was needed so that they could be used as dictionary keys. The guy with Perl in his background immediately asked if that's reliable --- a tuple can contain a list, which can be mutated. You've all heard this one more times than I have...
I guess you didn't try it:
t = ([0,1],2) d = {} d[t] = "hooey" Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: unhashable type
To pass the hash test, it needs to have immutable contents as well. To my mind, the "can act as dictionary key" argument is a red herring. Tuples and lists may technically be almost the same thing, but I find I hardly ever need to ponder whether I should use a tuple or a list. Tuples are structures and lists are containers. Yes, you can use a container as a structure. You can also use a bucket as a spoon. or-stick-your-head-straight-into-the-trough-ly y'rs - Gordon