What is the special method __new__() for?

Questions & AnswersCategory: PythonWhat is the special method __new__() for?
Lokesh Kumar Staff asked 2 years ago

What is the special method __new__() for?
a. The __new__() method is an informal representation of an object.
b. The __new__() method is called to create a new class.
c. The __new__() method is the formal representation of the object.
d. The __new__() method is used to create a new instance of the class.

1 Answers
Lokesh Kumar Staff answered 2 years ago

d. The __new__() method is used to create a new instance of the class.

Explanation:

object.__new__(cls[, ...]) – called to create a new instance of class cls.