June 2017
Beginner to intermediate
274 pages
6h 49m
English
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 ...
Read now
Unlock full access