when does __new__ becomes executed ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

when does __new__ becomes executed ?

does __new__ be executed before or after __init__ and does it be executed once or more ?

10th Apr 2021, 1:33 AM
Imrane Aabbou
Imrane Aabbou - avatar
2 Answers
+ 2
It is called whenever a new instance of the the class is created. It instantiates the object (self) and then passes self along with the other arguments that were passed in to the __init__ method.
10th Apr 2021, 2:28 AM
ChaoticDawg - avatar
+ 1
thank u for the simple answer broo.
15th Apr 2021, 10:09 PM
Imrane Aabbou
Imrane Aabbou - avatar