0
What is main __init__? please
1 Answer
+ 1
It is the constructor method. A method is a function associated to an object. This method is used to set the initial value of some attributes referred to the current instance of the class. For example if you create a class A with some attributes, like A.one, A.two, the code:
def __init__(self,a,b):
self.one = a
self.two = b
lets you to set the initial value for the attributes on the value that you want. The declaration a = A(8,9) sets a.one to 8 and a.two to 9.
The self parameter is a pointer, and refers to the current object.
The __init__ method is not required, but is generally useful for classes.