Chapter 4: Working with Metaclasses
Metaclasses, the focal point of this chapter, can manipulate the way a new class is created by decorating the arguments without impacting the actual class definition itself. Metaclasses are not very frequently used in Python application development unless there is a need for more advanced implementations of frameworks or APIs that need features such as manipulation of classes or dynamic class generation and so on.
In the previous chapter, we looked at the concept of decorators with some examples. Understanding decorators helps in following metaclasses with more ease since both decorators and metaclasses deal with metaprogramming on Python 3 program objects by manipulating them externally.
In this chapter, we will cover the following main topics:
- Overview of metaclasses
- The structure of a metaclass
- The application of metaclasses
- Switching metaclasses
- Inheritance in metaclasses
- Manipulating class variables
By...