+ 1
Fill in the blanks to make the egg attribute strongly private and access it from outside of the class
class Test: __egg = 7 t = Test() print(t._Test_____)
2 Réponses
+ 1
A strongly private attribute can be accessed as following:
class Test:
__egg = 10
t = Test()
print(t._Test__egg)
Note that you can always see the list of a Class attributes by using the dir() function
E.g:
print(dir(t))
0
Thanks