0

what's _init_ in python

what's _init_ in python

7th Sep 2018, 1:36 PM
kokito
2 Respuestas
+ 4
__init__ is a constructor of a class, a special function that is used to initialize the newly created object. It is called when you do obj=MyClass() Also, note that it has two underscores both at beggining and end
7th Sep 2018, 1:39 PM
michal
0
#Example: class food: def __init__(self, color, name): self.color = color self.name = name apple=food("red", "applename") print(apple.color) #red print(apple.name) #applename
7th Sep 2018, 6:44 PM
Sousou
Sousou - avatar