0
Please explain me why is the __init__ method so important in classes?? Give an example too!!
Please explain me why is the __init__ method so important in classes?? Give an example too!!
2 ответов
0
class Person :
def __init__(self, name):
self.name = name
lucky = Person("Lucky Nayak")
You created constructor using __init__ which automatically runs when instance is created and you can directly pass values. if you create method to access data you need to call them in each line to pass values.
0
Thanks manish