Is it possible monkey patch like this?
glicerinu at gmail.com
Tue Dec 18 11:26:42 CET 2012
I want to monkey patch a method that has lots of code so I want to avoid copying all the original method for changing just two lines. The thing is that I don't know how to do this kind of monkey patching.
Consider the following code:
def origina_method(self, *args, **kwargs):
if some_condition(): # This condition should be changed
#if some_condition(local_variable): # This condition should be added
# raise SomeException
Is it possible to tell Python to run the original method without stopping when an exception is raised? so I can catch them on a wrapper method and apply my conditional there.
Any other idea on how to monkey patch those two conditionals ?
More information about the Python-list