8th Nov 2019, 4:56 PM
NIMA
NIMA - avatar
2 odpowiedzi
+ 3
When you create an object, it calls __init__ method to initialize it. It is not really a constructor, since it doesn't create the object itself. In a class, self refers to the object itself (not the class name but an instance of this class). See classes as plans. You instanciate a new object following the plans. I.e : x = Person() You create here a new object of type Person.
8th Nov 2019, 9:46 PM
Théophile
Théophile - avatar
+ 2
`init` is the constructor function of `Person` class, and `self` is the `Person` object itself.
8th Nov 2019, 5:17 PM
o.gak
o.gak - avatar