What is the purpose of `__new__` in Python?

Python Professional Hard

Python Professional — Hard

What is the purpose of `__new__` in Python?

Key points

  • `__new__` is called before `__init__`
  • It is used to create the instance
  • Helps in customizing object creation
  • Not related to object copying

Ready to go further?

Related questions