Created
September 8, 2020 03:04
-
-
Save cloudhan/1c64d5a445e10b6c8371a793ee01dadd to your computer and use it in GitHub Desktop.
dynamic mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extend_instance(obj, cls): | |
"""Apply mixins to a class instance after creation""" | |
base_cls = obj.__class__ | |
base_cls_name = obj.__class__.__name__ | |
obj.__class__ = type(base_cls_name, (cls, base_cls), {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment