[Python-ideas] OrderedCounter and OrderedDefaultDict

Chris Angelico rosuav at gmail.com
Tue Oct 20 23:40:16 CEST 2015


On Wed, Oct 21, 2015 at 5:14 AM, Sven R. Kunze <srkunze at mail.de> wrote:
> 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

Yeah... that video is absolutely correct... for Ruby. In Python, you
can use multiple inheritance to do that in the exactly obvious way.

class EchoRandomHouse(EchoHouse, RandomHouse): pass

When I got to the bit in that video where she says that inheritance
paints you into a corner, I went and reimplemented her example code in
Python, and it's flawless. It doesn't even matter which order you put
the two superclasses, as there's no conflict.

ChrisA


More information about the Python-ideas mailing list