Today I Learned

Monkey patching

April 25, 2024

Monkey patching refers to the dynamic (run-time) modification of a class or module. It is an advanced topic in Python and involves altering the behavior of code during execution without changing the original source code.

It’s particularly useful for fixing bugs, adding missing features, or adapting third-party libraries to better suit specific requirements. Remember that while monkey patching provides flexibility, it should be used judiciously to avoid unintended side effects and maintain code readability

Reference

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


© 2026 - Written by Vuong Vu. Connect with me on LinkedIn.