Thoughts about Python

David H Wild dhwild at argonet.co.uk
Tue Feb 24 17:02:15 EST 2004


In article <15c2d03b.0402241237.708cb4e8 at posting.google.com>, Marco
Aschwanden <PPNTWIMBXFFC at spammotel.com> wrote:
> > Forget the speed and memory difference. The main argument for tuples
> > as a separate type are to use as dictionary keys. How do you propose
> > to handle dictionary keys without tuples?

> Maybe I don't get the point here: Why do dictionaries need tuples to
> work? I know that tuples can be used as keys... but how many times do
> you need tuples as dictionary keys (it would be simple to turn a list
> into an immutable string if really needed ("::".join(["a","b"]). But
> maybe tuples are used within dictionary in a way I don't know.

One of the reasons for doing this is that you can use a dictionary to
represent points with coordinates in a space of two or more dimensions. In
this case you need an immutable type, and you may need to get at its
elements.

-- 
 __  __  __  __      __ ___   _____________________________________________
|__||__)/ __/  \|\ ||_   |   / Acorn StrongArm Risc_PC
|  ||  \\__/\__/| \||__  |  /...Internet access for all Acorn RISC machines
___________________________/ dhwild at argonet.co.uk



More information about the Python-list mailing list