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

What is use of self and self.id in python?

12th Apr 2018, 9:00 PM
Raunak Jalan
Raunak Jalan - avatar
2 Answers
+ 2
self just a pointer to current object, self.id shows you current object’s id ...
12th Apr 2018, 9:22 PM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar
+ 1
If you have class and you want to get their attributes you have to use self statement. It is pointer on object which are you using now.
12th Apr 2018, 9:12 PM
Bartosz Pieszko
Bartosz Pieszko - avatar