Skip to content

Instantly share code, notes, and snippets.

View matbun's full-sized avatar

Matteo Bunino matbun

View GitHub Profile
matbun /
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):