What is the use of self in python?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the use of self in python??

27th Nov 2019, 12:11 PM
Pratik Kumbhar
Pratik Kumbhar - avatar
1 Answer
+ 8
Pratik Kumbhar See SoloLearn's Python course it has an lesson in OOP features where self method is explained well 'All methods must have self as their first it isn't explicitly passed, Python adds the self argument to the list for you; you do not need to include it when you call the methods. Within a method definition, self refers to the instance calling the method.' It is somehow same working like "this" of C++
27th Nov 2019, 12:25 PM
GAWEN STEASY
GAWEN STEASY - avatar