Still considering distinguishing between different types of inheritance. Apart from object composition or mix-in style, I want to illustrate something regarding the "arrow" of inheritance.
class super_dict(dict): def __init__(self, init={}, default_value=0, collision_function=None): *expands what dict can do* def get_default(self): #stupid method to illustrate a point return self._default_value class specialized_dict(dict): def update(self, other): *change the behavior of how updates work* def setdefault(self, key, value): if key=sentinel: self[key]=0 else: self[key]=value These look like the standard is-a inheritance, but they are very different. The first goes upwards, making a super-class, the other drills downwards and makes dict more specialized. The former expands on the capability and the API, the latter keeps the exact API but modifies the method behaviors. The former becomes a more general type, the latter becomes a more specific type. Steven D'Aprano was arguing a couple of years ago that there is no difference, one can simply turn the inheritance diagram upside-down. But here it can be seen that that's not an option Anyone else see the significance? Sorry to be a PITA... Mark -- https://mail.python.org/mailman/listinfo/python-list