Python OOP Tutorials | Python __init__, Constructors and Self

preview_player
Показать описание
In this Python Tutorial for Beginners video I am going to show How to use __init__ method and self self keyword in python. 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++.
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.
#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!
Рекомендации по теме
Комментарии
Автор

Honestly: you're a brilliant teacher. Very clearly and simply explained, using a pace that a new learner can follow along with. Very well done! Thank you for your contribution to developers-in-training.

alainlipowicz
Автор

You solidify my understanding of __init__

Thanks

patrickknows
Автор

Nicely explained. Easy to follow.
Thanks.

dayanandarajapakse
Автор

It's a clear explanation. Thank you for the Lecture.

rajapratappedapudi
Автор

Can you please give an example of passing a function as argument esp during the creation of object

arpitagec
Автор

About copy constructor. Systax of it in python?

duonghuynhnhan
Автор

Java doesn't have a destructor but c++ does have as far as I know.

aryaparvizi
Автор

Self is not a keyword please correct it

adnanshah