0
OOP
How would the attribute __a of the class b be accessed from outside the class?
2 Answers
+ 3
Its called pseudo private class variable, with the two underscores prefix. They are not truly private, just a bit obfuscated.
This is how you can access them:
https://code.sololearn.com/caqn8lQkDFKt/?ref=app
+ 3
With instantiating the class:
t = b()
print(t._b__a)
Without instantiating:
print(b.__dict__['_b__a'])