Chain Multiple Decorators in Python Last Updated : 01 Aug, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will try to understand the basic concept behind how to make function decorators and chain them together we will also try to see Python decorator examples. What is Decorator In Python?A decorator is a function that can take a function as an argument and extend its functionality and return a modified function with extended functionality. So, here in this post, we are going to learn about Decorator Chaining. Chaining decorators means applying more than one decorator inside a function. Python allows us to implement more than one decorator to a function. It makes decorators useful for reusable building blocks as it accumulates several effects together. It is also known as nested decorators in Python. we will also see Python decorator examples.Syntax of decorator in python@decor1@decordef num(): statement(s) Example 1: For num() function we are applying 2 decorator functions. Firstly the inner decorator will work and then the outer decorator. Python # code for testing decorator chaining def decor1(func): def inner(): x = func() return x * x return inner def decor(func): def inner(): x = func() return 2 * x return inner @decor1 @decor def num(): return 10 print(num()) Output:400Example 2:For sayhellogfg() and saygfg function, we are applying 2 decorator functions. Firstly the inner decorator(decor1) will work and then the outer decorator(decor2), and after that, the function datawill be printed. Python def decor1(func): def wrap(): print("************") func() print("************") return wrap def decor2(func): def wrap(): print("@@@@@@@@@@@@") func() print("@@@@@@@@@@@@") return wrap @decor1 @decor2 def sayhellogfg(): print("Hello") def saygfg(): print("GeekforGeeks") sayhellogfg() saygfg() Output:************@@@@@@@@@@@@Hello@@@@@@@@@@@@************GeekforGeeksYou can also learn about Generator in Python. Comment More infoAdvertise with us Next Article Chain Multiple Decorators in Python P pandeydeepa447 Follow Improve Article Tags : Python Python Decorators Practice Tags : python Similar Reads call() decorator in Python Python Decorators are important features of the language that allow a programmer to modify the behavior of a class. These features are added functionally to the existing code. This is a type of metaprogramming when the program is modified at compile time. The decorators can be used to inject modifie 3 min read Nested Decorators in Python Everything in Python is an object. Even function is a type of object in Python. Decorators are a special type of function which return a wrapper function. They are considered very powerful in Python and are used to modify the behaviour of a function temporarily without changing its actual value. Nes 2 min read Decorators in Python In Python, decorators are a powerful and flexible way to modify or extend the behavior of functions or methods, without changing their actual code. A decorator is essentially a function that takes another function as an argument and returns a new function with enhanced functionality. Decorators are 10 min read Conditional Decorators in Python In Python, decorators are functions or classes that wrap around a function as a wrapper by taking a function as input and returning out a callable. They allow the creation of reusable building code blocks that can either change or extend behavior of other functions. Conditional Decorators Given a co 2 min read Debugging decorators in Python Decorators in Python are really a very powerful feature. If you are a web developer and you have used the Django framework or even some other development frameworks you would have already come across decorators. For an overview decorators are wrapper functions that wrap an existing function or a met 3 min read Like