My last few posts have been about big, (overly) complicated code I wrote. Let’s change it up and talk about this eight-line function instead: def patch(existing_cls): def decorator(new_cls): for attr in dir(new_cls): obj = getattr(new_cls, attr)
Patching Existing Python Classes
Patching Existing Python Classes
Patching Existing Python Classes
My last few posts have been about big, (overly) complicated code I wrote. Let’s change it up and talk about this eight-line function instead: def patch(existing_cls): def decorator(new_cls): for attr in dir(new_cls): obj = getattr(new_cls, attr)