What is the purpose of Python’s __set_name__ combined with a class decorator, and in what order are they called?

Python Professional Hard

Python Professional — Hard

What is the purpose of Python’s __set_name__ combined with a class decorator, and in what order are they called?

Key points

  • __set_name__ is called before the class decorator runs
  • Helps set the name of the descriptor early in the class creation process
  • Class decorators receive the fully constructed class after __set_name__ has completed

Ready to go further?

Related questions