I'm reading this article: https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
He's trying to explain the purpose of a 'mix-in class' and he says
We did not alter the source code for
LoggingDict
. Instead we built a subclass whose only logic is to compose two existing classes and control their search order.
class LoggingOD(LoggingDict, collections.OrderedDict):
pass
My question is this: in the above article context, is he talking about the LoggingDict
's search order that is being manipulated? Or he is talking about manipulating the LoggingOD
search order?
He says very clearly "not alter the source code for LoggingDict
" so clearly he means that somehow, magically - the search order for super().__setitem__
in
class LoggingDict(dict):
def __setitem__(self, key, value):
logging.info('Settingto %r' % (key, value))
super().__setitem__(key, value)
is being altered/influenced, but how? Could someone clarify what exactly is going on here? Far as I can make of it, the tree looks like this: