what is monkey-patching in Python?
Monkey-patching is when you alter the run-time behavior of an object at runtime. In Python, this is done by modifying the object's attributes, such as by assigning a new field, modifying a function, or dynamically changing the base class.

Here's an example of monkey-patching from the pandas documentation:

```python
import pandas as pd
def just_foo_cols(self):
    """Get a list of column names containing the string 'foo'

    """
    return [x for x in self.columns if 'foo' in x]

pd.DataFrame.just_foo_cols = just_foo_cols # monkey-patch the DataFrame class
df = pd.DataFrame([list(range(4))], columns=["A","foo","foozball","bar"])
df.just_foo_cols()
del pd.DataFrame.just_foo_cols # you can also remove the new method
```

The monkey-patching occurs in this line

```python
pd.DataFrame.just_foo_cols = just_foo_cols # monkey-patch the DataFrame class
```

Where we dynamically add a the method `just_foo_calls` to pandas `DataFrame`. Then we can call the method on all instances, as shown in this line

```python
df.just_foo_cols()
```

Monkey-patching also occurs in this-line

```python
del pd.DataFrame.just_foo_cols # you can also remove the new method
```

where we delete the method so it can no longer be called (we could delete an existing method, too).

Monkey-patching is often considered bad design. The patches may break other libraries and unrelated code which rely on the old behaviors. Furthermore, it makes the code harder to understand, because a single object is now defined in multiple places (the actual definition and where it's monkey-patched); it's almost always better to simply modify the base code.

But monkey-patching has its uses, primarily when you don't have the ability to modify the base code (because it's in an external library like pandas), and when your object modifications are highly unlikely to break downstream code (e.g. adding a new method with a unique name, or changing a class into a "Proxy" which has the exact same behavior but does something like trace calls).

Here are some external sites for more info:

- Stack overflow post clarifying monkey patching in Python, and providing some benefits and drawbacks: https://stackoverflow.com/questions/5626193/what-is-monkey-patching

- Wikipedia: https://en.wikipedia.org/wiki/Monkey_patch