Re: Thoughts about Python
Marco Aschwanden wrote:[color=blue][color=green][color=darkred]
>>>*** Problem: tuples are not necessary[/color]
>>
>>Says you! Here's a hint: hash([]).
>>
>>[...][/color]
>
>
> 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).[/color]
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@despamm ed.com
ICQ: 66750646
AIM: pantear
Homepage: http://andres980.tripod.com/
Random Thought:[color=blue]
>[/color]
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
Marco Aschwanden wrote:[color=blue][color=green][color=darkred]
>>>*** Problem: tuples are not necessary[/color]
>>
>>Says you! Here's a hint: hash([]).
>>
>>[...][/color]
>
>
> 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).[/color]
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@despamm ed.com
ICQ: 66750646
AIM: pantear
Homepage: http://andres980.tripod.com/
Random Thought:[color=blue]
>[/color]
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
Comment