class MyClass():
def __init__(self, name, high=None, low=None):
self.name = name
if low:
self.low = low
elif high:
self.high = high
else:
raise Error("Not found")
def __repr__(self):
value = self.low or self.high
return '{}({}, {})'.format(str(self), self.name, value)
I have a unit test case, in which MyClass is being instantiated like,
gain = MyClass('name', high='high_value')
assert isinstance(repr(gain), str)
But when my repr() is called, it is throwing AttributeError,
AttributeError: 'MyClass' has no attribute 'low'