Advanced Python: Metaprogramming
Explaining what, why and how Metaprogramming works in Python
Metaprogramming is a complex yet one of the most interesting topics in Python programming language. Metaprogramming makes the Python programming language extremely powerful.
We have come across decorators. We often use decorators to enhance the Python code and add extra functionality to the existing functions/classes. These decorators are part of metaprogramming in Python.
Code generators are also part of metaprogramming. We can introspect the functions, classes, types of an object and modify them at runtime. The IDEs use the metaprogramming feature to provide code analysis.
This article will illustrate what Metaprogramming is, where it can be used, and how it works in practice.
Expert level Python developers, who intend to implement frameworks and their own libraries in Python often use the Metaprogramming features of Python.
This is an advanced level topic for Python developers and I recommend it to everyone who is/or intends in using the Python programming language.