In the previous chapter, we discussed asynchronous I/O and coroutines. In this chapter, we turn our attention to metaprogramming and programmable syntax. We'll discuss various ways that Python allows us to control or alter the meaning of syntactic elements and use these features beneficially.
We'll look at another programmable syntax feature of Python that meshes nicely with function decorators. We'll also discuss class decorators and how they're similar to, and different from, function decorators. Then we'll see a different way of programmatically modifying classes using metaclasses. We'll move on to a less esoteric topic and discuss context managers. Finally, we'll look at one more way of programming the semantics of basic Python operations when we look at descriptors.
Metaprogramming is a blanket term for techniques where programs...