New course! Every coder should learn Generative AI!
Try a free lesson+ 9
Have a look at this
class Spam:
__egg = 7
def print_egg(self):
print(self.__egg)
s = Spam()
s.print_egg()
print(s._Spam__egg)
print(s.__egg)
As you can see, you can access the private method of s with s._Spam__egg
Being that the case, if you want to use the private method egg from Spam you have to use _Spam__egg.
Because of that it's not _b.__a and it is instead _b__a