Thoughts about Python

Andres Rosado-Sepulveda arosado at softhome.net
Tue Feb 24 17:35:48 EST 2004


Marco Aschwanden wrote:
>>>*** Problem: tuples are not necessary
>>
>>Says you!  Here's a hint: hash([]).
>>
>>[...]
> 
> 
> I suppose this is the argument: list are not immutable that is why
> they cannot be used a dict key... I wonder how many people use a tuple
> as dict key. This seems to be a common practice to justify its own
> "type". I admit, I can think of simple workarounds when there wouldn't
> be tuples (eg. Instead of transforming a list into tuple why not
> transforming it into a string).

I sometimes I use it. Especially if I use dates, where it makes sorting 
so much easier. But it does have its usefulness.

Transforming a list to a string is not very good, because tuples may 
contain user-defined classes that overwrite __lt__ and not __str__.

-- 
Andres Rosado
Email: andresr at despammed.com
ICQ: 66750646
AIM: pantear
Homepage: http://andres980.tripod.com/

Random Thought:
 >
I'm just as sad as sad can be!
     I've missed your special date.
Please say that you're not mad at me
     My tax return is late.
         -- Modern Lines for Modern Greeting Cards



More information about the Python-list mailing list