def __init__(self):
    """Loop on all base classes, and invoke their constructors.
    Protect against diamond inheritance."""
    for base in self.__class__.__bases__:
        # Avoid problems with diamond inheritance.
        basekey = 'init_' + str(base)
        if not hassattr(self, basekey):
            setattr(self, basekey, 1)
        else:
            continue
        # Call this base class' constructor if it has one.
        if hasattr(base, "__init__"):
            base.__init__(self)
Loop on all base classes, and invoke their constructors.
    Protect against diamond inheritance.
recipes/Python/146462_Constructor_Destructor/recipe-146462.py