Vidyalelo
Python · Q16

Decorators in Depth

Programming · Python · question 16

Q16

What is the purpose of the @classmethod decorator in Python?

A.
To define a class method
Answer
B.
To define an instance method
C.
To define a static method
D.
To define a constructor method

Answer: Option A

Solution

Answer: Option A
Solution:
The @classmethod decorator is used to define a method that operates on the class and not just instances.