Domanda di colloquio di TensorIoT

What is moneky patching

Risposta di colloquio

Anonimo

27 dic 2021

We can change the behavior of the code at run time (Dynamic modifications) is called monkey patching. # parent.py class A: def func_a(self): print ("func_a() is called") In another file where we will update the whole function as below import parent def monkey_func(self): print ("monkey_func() is called") parent.A.func_a = monkey_function obj = parent.A() obj.func_a() # o/p monkey_func() is called