Variables declared inside init function of a class | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Variables declared inside init function of a class

Variables declared inside init function of a class can be used inside other functions of the same class But, Variables declared inside any other function of a class cannot be used inside other functions of the same class can u tell my why this happens?

26th Jan 2017, 4:14 PM
Arjun Katyal
Arjun Katyal - avatar
2 Respuestas
+ 4
That should work. Maybe you're using an outdated version of Python. @_@
26th Jan 2017, 4:35 PM
Caleb Jore
Caleb Jore - avatar
0
I got it sorted out. self was missing due to which I was not able to access that variable in other functions of same class. but, self was present in the init function.
26th Jan 2017, 4:39 PM
Arjun Katyal
Arjun Katyal - avatar