Advanced Python: Metaprogramming

Explaining what, why and how Metaprogramming works in Python

Farhad Malik
FinTechExplained

--

Metaprogramming is a complex yet one of the most interesting topics in Python programming language. Metaprogramming makes the Python programming language extremely powerful.

Metaclass is above classes

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.

--

--

Farhad Malik
FinTechExplained

My personal blog, aiming to explain complex mathematical, financial and technological concepts in simple terms. Contact: FarhadMalik84@googlemail.com