Monkey Patching Python Code
Python is a dynamic scripting language. Not only does it have a dynamic type system where a variable can be assigned to one type first and changed later, but its object model is also dynamic. This allows us to modify its behavior at run time. A consequence of this is the possibility of monkey patching. This is an idea that we can modify the base layer of a program without modifying the higher-level code. Imagine you can use the print()
function to print something to the screen, and we can modify the definition of this function to print it to a file without modifying any single line of your code.
It is possible because Python is an interpreted language,