filmov
tv
Python Tutorial for Beginners 26 - Is it possible to define multiple constructors in Python?

Показать описание
In this Python Tutorial for Beginners video I am going to show if it Is possible to define multiple constructors in Python?.
Unlike Java or C++, we cannot define multiple constructors in python. but, we can define a default value if one is not passed or we can use *args, **kwargs as arguments.
So what does the __init__ method do in python ? __init__ method is used as a constructor for the class. Usually __init__ does some initialization work e.g. initialize attributes and other functions.The arguments passed to the class name are given to its __init__() method. It would be incorrect to call __init__ constructor of the class.But __init__ is the closest thing we're going to get in Python to a constructor.
And what is self in python - self is the first argument of every method is a reference to the current instance of the class. self keyword is similar to the keyword this in Java or C++.
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Unlike Java or C++, we cannot define multiple constructors in python. but, we can define a default value if one is not passed or we can use *args, **kwargs as arguments.
So what does the __init__ method do in python ? __init__ method is used as a constructor for the class. Usually __init__ does some initialization work e.g. initialize attributes and other functions.The arguments passed to the class name are given to its __init__() method. It would be incorrect to call __init__ constructor of the class.But __init__ is the closest thing we're going to get in Python to a constructor.
And what is self in python - self is the first argument of every method is a reference to the current instance of the class. self keyword is similar to the keyword this in Java or C++.
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Комментарии