In many discussions I have heard about Ruby in which people have expressed their reservations about the language, the issue of monkey patching comes up as one of their primary c
If you want to do some monkey patching in Python, it is relatively easy, as long as you are not modifying a built-in type (int, float, str).
class SomeClass:
def foo(self):
print "foo"
def tempfunc(self):
print "bar"
SomeClass.bar = tempfunc
del tempfunc
This will add the bar method to SomeClass and even existing instances of that class can use that injected method.