(original) (raw)
On Wed, Jan 2, 2013 at 1:13 PM, Masklinn�<masklinn@masklinn.net>�wrote:
Wouldn't it make more sense to provide e.g.
collections.KeyedDictionary(key, seq, \*\*kwargs)? It would be clear
and would allow implementations to provide dedicated implementations for
special cases (such as key=id) if desired or necessary.
defaultdict already follows this pattern, so there's a precedent.
I agree collections is the place to put it but that would give us three specialized subclasses of dictionary which cannot be combined. That is, I can have a dictionary with a default, one that is ordered or one that uses a key function but not any combination of those. It would seem better to have something like�Haoyi Li suggested:
collections.Dictionary(default=None, ordered=False, key=None) --> a dict subclass
of course collections.OrderedDictionary�and collections.defaultdict would continue to be available as appropriate aliases to collections.Dictionary.
--- Bruce
Check it out:�http://kck.st/YeqGxQ