In this section, we'll look at class decorators, which are conceptually similar to function decorators but open different doors.
Class decorators work in the same basic way that function decorators do. A class decorator receives the class as its only parameter, and whatever it returns replaces that class. This is illustrated in the following image:
The return value doesn't have to be the same class or even a class at all, but it should be something that is meaningful. When it's bound to the class's name, it's rarely useful for a decorator to return none.
Also, like a function decorator, a class decorator can modify the attributes of the class or enclose the whole class in wrapper code. However, modifying the attributes of the class is effectively the same as modifying the class of the source code. This means that unlike functions, a class...