def add_mixin(cls, mixin, force=False):
    """Add the public attributes of a mixin to another class.

    Attribute name collisions result in a TypeError if force is False.
    If a mixin is an ABC, the decorated class is registered to it,
    indicating that the class implements the mixin's interface.

    """

    for name, value in mixin.__dict__.items():
        if name.startswith("_"):
            continue
        if not force and hasattr(cls, name):
            raise TypeError("name collision ({})".format(name))
        setattr(cls, name, value)
    try:
        mixin.register(cls)
    except AttributeError:
        pass
Add the public attributes of a mixin to another class.

    Attribute name collisions result in a TypeError if force is False.
    If a mixin is an ABC, the decorated class is registered to it,
    indicating that the class implements the mixin's interface.

    
recipes/Python/577824_Mixins_Inheritance_vs_DecoratorLets_Try/recipe-577824.py