I\'ve read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python.
I understand that it\'s not always good to do so
In Python monkeypatching generally works by overwriting a class or function's signature with your own. Below is an example from the Zope Wiki:
from SomeOtherProduct.SomeModule import SomeClass
def speak(self):
return "ook ook eee eee eee!"
SomeClass.speak = speak
This code will overwrite/create a method called peak
in the class. In Jeff Atwood's recent post on monkey patching, he showed an example in C# 3.0 which is the current language I use for work.