Monkey-patching a new method to an object
import types
class MyClass(object):
def __init__(self, value):
self.value = value
c = MyClass(42)
def print_value(self):
print(self.value)
c.print_value = types.MethodType(print_value, c)
c.print_value()INFO