what is the SELF object in python ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

what is the SELF object in python ?

why do we use the self object in every function definition.

11th Apr 2017, 2:54 AM
Kaushik Roy
Kaushik Roy - avatar
2 ответов
+ 1
self object is an instance of the class you are in. It's usefull when for example your class has a variable named test and the constructor receives a parameter called test too. The only way to distinguish these 2 things is to use self when you refer to the class member and nothing when you refer to the parameter.
11th Apr 2017, 4:51 AM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
0
thank u
12th Apr 2017, 3:10 AM
Kaushik Roy
Kaushik Roy - avatar