Re: "Ordered" dicts



Delaney, Timothy (Tim) wrote:
Martin Miller wrote:


To avoid continued reinvention of this wheel, I'd also vote to have
this functionality be at least included in a standard module, if not
built-in.


This has been discussed on python-dev (I proposed it actually). The
final consensus was that no such implementation would be included at
this time, as it's a pretty simple thing to implement, and there are
already several implementations in the Cookbook.

My arguments included the fact that there were several implementations
in the Cookbook as an indication it should be included in the standard
library ...

Thread starts here:
http://mail.python.org/pipermail/python-dev/2005-March/051915.html

Tim Delaney
I have a module "dictionaries.py" which might be of interest.

The __doc__ says:

'''
  To provide the classes rDict (restricted dictionary), oDict
  (ordered according to time of entry) and sDict (sorted dictionary).
  oDict delivers keys or items in the order in which they were
  inserted.

  rDict has keys restricted to either those identified initially,
  or those added with newEntry.

  sDict delivers keys and items in sorted order.

'''
It is available in the zip file (http://www3.sympatico.ca/cjw/PyMatrix/PyMatrix.zip) for the PyMatrix package. The zip file (176 KB) contains lots of irrelevant stuff.


I would be glad to mail the dictionaries.py to anyone who is interested
with the usual lack of warranty.

Colin W.
.