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!!

16th May 2020, 5:10 AM
Lucky Nayak
Lucky Nayak - avatar
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.
16th May 2020, 5:30 AM
Manish
Manish - avatar
0
Thanks manish
17th May 2020, 7:35 PM
Lucky Nayak
Lucky Nayak - avatar