OOP | Sololearn: Learn to code for FREE!



How would the attribute __a of the class b be accessed from outside the class?

2/22/2019 4:49:29 PM

Joanes Lúcio Ferreira

2 Answers

New Answer


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


With instantiating the class: t = b() print(t._b__a) Without instantiating: print(b.__dict__['_b__a'])