test object has no attribute error happend by name mangling

technical talkiess
0

 


Private variable ko aap agar direct access karte ho to apko niche wala error atta hai 

print(vishal.__name_of_person)


AAp direct aise use nahi kar sakte ho … usko python me name mangling se nahi pateho 


solution :-

Ex :- print(vishal._ClassName__name_of_person))

 

Traceback (most recent call last):

  File "c:\Users\ukv-208\Downloads\prac\python\oops.py", line 28, in <module>

    print(vishal.__name_of_person)

          ^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: 'test' object has no attribute '__name_of_person'


Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)