culTest

    One of the 50 questions in this topic

    How much do you know about Python?

    What is a class decorator in Python?

    Answers

    A class that decorates graphical interfaces
    A function that takes a class as input and returns a modified classCorrect
    A special method within a class
    A class that inherits from multiple classes

    A class decorator is a function that takes a class as input and returns a modified or enhanced class. It is applied with the @decorator syntax before the class definition. Unlike more common function decorators, they modify the entire class rather than a single method. Examples include dataclasses.dataclass, which automatically generates methods such as __init__ and __repr__, or abc.abstractmethod for defining abstract interfaces.