sorteddict PEP proposal [started off as orderedict]
Paul Rubin
http
Wed Sep 26 14:51:49 EDT 2007
Mark Summerfield <m.n.summerfield at googlemail.com> writes:
> The sorteddict API that has emerged so far is (1) apart from the
> constructor, everything is identical to dict,
I don't see this as necessary, it's ok if it resembles dict as much
as dbm does.
> (2) the constructor takes the same args as sorted(), so if you want
> to seed with a dict or with keywords you write
> sorteddict(dict(a=1,b=2), ...), (or you could create a sorteddict
> and use update() since that takes the same args as dict's
> constructor).
sorteddict could itself return a constructor:
d = sorteddict(key=int).new((('12', 'a'), ('3', 'b')))
gives sorted version of {'3':'b', '12':'a'}
More information about the Python-list
mailing list