The dynamic modifications made to a class or module at runtime are termed as monkey patching in Python. Consider the following code snippet:
# m.py
class MyClass:
def f(self):
print "f()"
We can monkey-patch the program something like this:
import m
def monkey_f(self):
print "monkey_f()"
m.MyClass.f = monkey_f
obj = m.MyClass()
obj.f()
The output for the program will be monkey_f().
The examples demonstrate changes made in the behavior of f() in MyClass using the function we defined i.e. monkey_f() outside of the module m.