I've read this in the docs:
The instantiation operation (“calling” a class object) creates an empty object. Many classes like to create objects with instances customized to a specific initial state. Therefore a class may define a special method named init(), like this:
def __init__(self):
self.data = []
I wonder, what is the advantage of creating a __init__ function with no statements/commands in it?
If only for declaring variables, you could also do this in the clause of the class definition. What is the difference between the following two class definitions:
# form 1
class MyClass:
name = "Kuku"
# form 2
class MyClass:
__init__(self):
self.name = "Kuku"