In Python, the term monkey patch refers to dynamic (or run-time) modifications of a class or module. In Python, we can actually change the behavior of code at run-time.
We use above module (monk) in below code and change behavior of func() at run-time by assigning different value.
Output :monkey_f() is being called
- Python | Unit Test Objects Patching | Set-2
- Python | Unit Test Objects Patching | Set-1
- Implementation of Dynamic Array in Python
- Type Systems:Dynamic Typing, Static Typing & Duck Typing
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Python | Index of Non-Zero elements in Python list
- Python | Add Logging to Python Libraries
- Python | Add Logging to a Python Script
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- bin() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.