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 Indentation in Python In Python, indentation is used to define blocks of code. It tells the Python interpreter that a group of statements belongs to a specific block. All statements with the same level of indentation are considered part of the same block. Indentation is achieved using whitespace (spaces or tabs) at the b 2 min read asyncio in Python Asyncio is a Python library that is used for concurrent programming, including the use of async iterator in Python. It is not multi-threading or multi-processing. Asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance network and web servers, databa 4 min read Last Minute Notes (LMNs) - Python Programming Python is a widely-used programming language, celebrated for its simplicity, comprehensive features, and extensive library support. This "Last Minute Notes" article aims to offer a quick, concise overview of essential Python topics, including data types, operators, control flow statements, functions 15+ min read Incremental Programming in Python In incremental systems, every measurement refers to a previously dimensioned position (point-to-point). Incremental dimensions are the distances between two adjacent points. An incremental movement moves A distance based on your current position. Start Small - First of all, start your program small 2 min read Interesting facts about Python Lists Python lists are one of the most powerful and flexible data structures. Their ability to store mixed data types, support dynamic resizing and provide advanced features like list comprehension makes them an essential tool for Python developers. However, understanding their quirks, like memory usage a 6 min read Like