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 Ferreira2 Answers
New AnswerIts 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'])
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message