C
Chris
Is there any way to make the class Z behave the same way as class Y?
Chris
class Y:
value = 42
def __hasattr__(self, name):
if name == '__int__':
return True
def __getattr__(self, name):
if name == '__int__':
return lambda: self.value
class Z(object):
value = 42
def __hasattr__(self, name):
if name == '__int__':
return True
def __getattr__(self, name):
if name == '__int__':
return lambda: self.value
TypeError: int() argument must be a string or a number
Chris
class Y:
value = 42
def __hasattr__(self, name):
if name == '__int__':
return True
def __getattr__(self, name):
if name == '__int__':
return lambda: self.value
class Z(object):
value = 42
def __hasattr__(self, name):
if name == '__int__':
return True
def __getattr__(self, name):
if name == '__int__':
return lambda: self.value
TypeError: int() argument must be a string or a number