Summary
In this chapter, we have learned how to create simple decorators and how to apply decorators with examples. We saw how to exchange decorators from one function to another along with how to add multiple decorators to one function.
We now understand the concept of class decorators and have looked at an example of how to apply them. And finally, we learned how to use some built-in decorators such as @staticmethod
and @classmethod
.
All of these concepts are part of Python metaprogramming and they are used to change the behavior of a function or a method externally and without impacting the internal functionalities of the function or method.
In the next chapter, we will be looking at the concept of meta classes with different examples.