In article <[EMAIL PROTECTED]>, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >Cameron Laird wrote: > >> In article <[EMAIL PROTECTED]>, >> Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>>Martin Marcher wrote: >>> >>>> On 2008-08-26 00:32:20, cnb wrote: >>>>> Are dictionaries the same as hashtables? >> . >> . >> . >>>Python does not have a "one key maps to a list of values"-semantics - >>>which I consider the sane choice... >>> >>>However, you can have that using the defaultdict for example: >>> >>>listdict = defaultdict(list) >>> >>>listdict[key].append(value) >>> >>>Diez >> >> ? I'm lost. As I understand your terms, Python's dictionaries >> map keys to objects, but you would prefer that Python's >> dictionaries map keys only to lists of values. That *sounds* >> like a complexification, at best. Are you trying to make a >> point about implementation aligning with semantics? > >The OP seems to want that (or at least sees it as one of two viable design >choices), see his other answer in this thread. > >I certainly *don't* agree with that, I merely pointed out that python comes >with means to easily create such a data-structure in the case it is needed. > >Diez
Oh! Thanks for clearing *that* up; I certainly had a different impression. To the original poster then: please be aware that the values of Python's dictionaries not only can be any first-class objects, but it's quite common--quite common in *my* code, anyway--for dictionaries to range over lists, tuples, functions, other dictionaries, and more. Python needn't change to allow you to write any of this. -- http://mail.python.org/mailman/listinfo/python-list