Which decorator is used to define a class method in Python?

Options

  • A. @staticmethod
  • B. @classmethod
  • C. @property
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. @classmethod

Detailed Explanation

The @classmethod decorator creates a method that receives the class itself as its first argument, conventionally named cls.