Monkey Patching in Python (Dynamic Behavior) Last Updated : 04 Dec, 2020 Comments Improve Suggest changes Like Article Like Report 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. Python3 1== # monk.py class A: def func(self): print ("func() is being called") We use above module (monk) in below code and change behavior of func() at run-time by assigning different value. Python3 1== import monk def monkey_f(self): print ("monkey_f() is being called") # replacing address of "func" with "monkey_f" monk.A.func = monkey_f obj = monk.A() # calling function "func" whose address got replaced # with function "monkey_f()" obj.func() Examples: Output :monkey_f() is being called Comment More infoAdvertise with us Next Article Monkey Patching in Python (Dynamic Behavior) R ravindra prajapati Follow Improve Article Tags : Python Practice Tags : python Similar Reads Implementation of Dynamic Array in Python What is a dynamic array? A dynamic array is similar to an array, but with the difference that its size can be dynamically modified at runtime. Don't need to specify how much large an array beforehand. The elements of an array occupy a contiguous block of memory, and once created, its size cannot be 4 min read Dynamic Attributes in Python Dynamic attributes in Python are terminologies for attributes that are defined at runtime, after creating the objects or instances. In Python we call all functions, methods also as an object. So you can define a dynamic instance attribute for nearly anything in Python. Consider the below example for 2 min read Python | Implementing Dynamic programming using Dictionary Dynamic Programming is one way which can be used as an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems so that we do not have to r 3 min read Create Classes Dynamically in Python A class defines a collection of instance variables and methods to specify an object type. A class can be used to make as many object instances of the type of object as needed. An object is an identified entity with certain attributes (data members) and behaviours (member functions). Group of objects 2 min read Functional Programming in Python Functional programming is a programming paradigm in which we try to bind everything in a pure mathematical functions style. It is a declarative type of programming style. Its main focus is on " what to solve" in contrast to an imperative style where the main focus is "how to solve". It uses expressi 10 min read Like