good name for a dict/list hybrid

Andrew Dalke adalke at
Thu Jan 9 04:48:30 CET 2003

Beni Cherniavsky:
 > The main issue to decide is
> whether you care for the order between different keys.  If not, your
> semantics are just an unordered mapping from keys to ordered lists of
> values: {'Name': ['Andrew', 'Andrew Dalke'], 'Lang': ['English'], ...}
> In that case you might be satisfied with just a dict mapping to
> lists, otherwise try "DictList", "ListDict", "MultiDict", "mdict"...

Nearly all of the keys are unique in my data set, at least from
observation.  The data provider says some keys may be duplicated,
so I want to make it easy to get the common case (key/value) like it
was a simple dictionary but also have a way to get the rare case of

So while that approach works, it doesn't make the common case as
simple as I wanted.

> If you do care for the complete order, your semantics are just a list
> of pairs.  Then you surely need to write a class, since access by keys is
> inconveneint for just a list pair.  I suggest calling it "PairList".

For other tasks (not in my original spec) I've needed the simplicity of 
key/value lookups but order preserving, so that I can round-trip a
data format.

The code I posted elsewhere I believe handles all my expected needs.

					dalke at

More information about the Python-list mailing list