Top "Monkeypatching" questions

Dynamically modifying run-time behavior by replacing program elements with new program elements

Adding a Method to an Existing Object Instance

I've read that it is possible to add a method to an existing object (i.e., not in the class …

python oop methods monkeypatching
How to add property to a class dynamically?

The goal is to create a mock class which behaves like a db resultset. So for example, if a database …

python properties runtime monkeypatching
What is monkey patching?

I am trying to understand, what is monkey patching or a monkey patch? Is that something like methods/operators overloading …

python terminology monkeypatching
When monkey patching an instance method, can you call the overridden method from the new implementation?

Say I am monkey patching a method in a class, how could I call the overridden method from the overriding …

ruby monkeypatching
Making object JSON serializable with regular encoder

The regular way of JSON-serializing custom non-serializable objects is to subclass json.JSONEncoder and then pass a custom encoder to …

python json serialization monkeypatching
Monkey patching a class in another module in Python

I'm working with a module written by someone else. I'd like to monkey patch the __init__ method of a class …

python class unit-testing monkeypatching
How does one monkey patch a function in python?

I'm having trouble replacing a function from a different module with another function and it's driving me crazy. Let's say …

python monkeypatching
Can I patch a Python decorator before it wraps a function?

I have a function with a decorator that I'm trying test with the help of the Python Mock library. I'd …

python unit-testing mocking decorator monkeypatching
Conjugate transpose operator ".H" in numpy

It is very convenient in numpy to use the .T attribute to get a transposed version of an ndarray. However, …

python arrays numpy matrix monkeypatching
Monkey-patch Python class

I've got a class, located in a separate module, which I can't change. from module import MyClass class ReplaceClass(object) ... …

python monkeypatching