Skip to content

Instantly share code, notes, and snippets.

View matbun's full-sized avatar
🎯
Focusing

Matteo Bunino matbun

🎯
Focusing
View GitHub Profile
@matbun
matbun / add_metods_dyn.py
Created August 11, 2023 13:29
Python - Add methods dynamically to a class (from another class)
"""MethodType for dynamic appending methods to classes"""
from types import MethodType
class A:
def __init__(self) -> None:
self.n = 0
def inc(self):