I have the following class:
class Members(object):
def __init__(self, variable=50):
self.__myvariable = variable
def getVariable(self):
return self.__myvariable
# attempt 1
def __repr__(self):
return """{self.__class__.__name__}({self.getVariable()})""".format(self=self)
# attempt 2
def __repr__(self):
return """{self.__class__.__name__}({self.__myvariable})""".format(self=self)
I cannot find a way to print the __ variables in a format string by using the self as a key, why is that so?
The error I get is
AttributeError: 'Members' object has no attribute 'getVariable()'
AttributeError: 'Members' object has no attribute '__myvariable