@@அருண்குமார்-ர5ள yes we are getting attribute error... in video it works fine.. because we have run the previous code so the next block of code runs properly.... but when we run the specific code block it shows error... it is because when we put print statement outside a function and within a class it will executed even before the object is created so we are getting that error.... class test: def detail(self): pass print("hai") If you run the above code you will get output hai..... here the print statement is executed as soon as we create and run the class even without creating the object... like wise when we run our previous code, print("Name: ",obj.name) print("Age: ",obj.age) the obj will not be created at that time of execution so we are getting that error... if you put the same print statements in another method it will work fine...
@@GURUKULAmam if you don't mind can you make one more video about public variable because public variable access method outside in jupyter notebook it was showing output without error but the same code run to python (idle,3.11) it's showing name error
mam private variable ah function ku veliya use panna mutiyalaye.ana ni use pannalam nu solriga
4:00 method ku veliya (class ku ulla ) obj va vachu public variablea access panna mudiyala mam. Attribute Error varuthu mam. Please explain this mam💖
class test:
def detail(self,name,age):
self.name=name
self.age=age
print("Name: ",obj.name)
print("Age: ",obj.age)
obj=test()
obj.detail("arun",23)
print("Name: ",obj.name)
print("Age: ",obj.age)
Output: AttributeError: 'text' object has no attribute 'name'
Please explain this mam
@@அருண்குமார்-ர5ள yes we are getting attribute error... in video it works fine.. because we have run the previous code so the next block of code runs properly.... but when we run the specific code block it shows error... it is because when we put print statement outside a function and within a class it will executed even before the object is created so we are getting that error....
class test:
def detail(self):
pass
print("hai")
If you run the above code you will get output hai..... here the print statement is executed as soon as we create and run the class even without creating the object...
like wise when we run our previous code,
print("Name: ",obj.name)
print("Age: ",obj.age)
the obj will not be created at that time of execution so we are getting that error... if you put the same print statements in another method it will work fine...
Mam jupyter notebook show output properly but python 3.11 idle was showing name error in this method
@@GURUKULAmam if you don't mind can you make one more video about public variable because public variable access method outside in jupyter notebook it was showing output without error but the same code run to python (idle,3.11) it's showing name error
Akka protected concept encapsulation la fasta podunga pls
Sure we will