In Python, the term monkey patching refers to the dynamic/run-time changes taking place within a class or module. Here's an example:

Note: Being one of the most sought after languages, Python is chosen by small and large organizations equally to help them tackle issues. Our list of Python Coding Interview Questions shall help you crack an interview in organizations using Python while making you a better Python Developer.

Example

                                        

import monk
def monkey_f(self):
     print "monkey_f() is being called"  
monk.A.func = monkey_f
obj = monk.A()
obj.func()

Output

monkey_f() is being called

Suggest An Answer

No suggestions Available!