[Python-ideas] OrderedCounter and OrderedDefaultDict
Sven R. Kunze
srkunze at mail.de
Tue Oct 20 20:14:31 CEST 2015
On 17.10.2015 04:08, Andrew Barnert via Python-ideas wrote:
> Actually, forget all that; it's even simpler.
>
> At least in recent 3.x, the only thing wrong with inheriting from both
> types, assuming you put OrderedDict first, is the __init__ signature. So:
>
> class OrderedDefaultDict(OrderedDict, defaultdict):
> def __init__(self, default_factory=None, *a, **kw):
> OrderedDict.__init__(self, *a, **kw)
> self.default_factory = default_factory
Not saying that inheritance is a bad thing but to me It seems to me that
ordering and default values should be orthogonal aspects of the standard
dict.
Just as Sandi described it here: https://www.youtube.com/watch?v=29MAL8pJImQ
Best,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151020/44c5cb35/attachment.html>
More information about the Python-ideas
mailing list