V
vijay shanker
hi
i have this class book
class book:
def __init__(self,name,price):
self.name = name
self.price = price
def __getattr__(self,attr):
if attr == '__str__':
print 'intercepting in-built method call '
return '%s:%s' %
(object.__getattribute__(self,'name'),object.__getattribute___(self,'price'))
else:
return self.__dict__[attr]
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<console>", line 11, in __getattr__
KeyError: '__repr__'
i am missing on a concept here. please enlighten me.
i have this class book
class book:
def __init__(self,name,price):
self.name = name
self.price = price
def __getattr__(self,attr):
if attr == '__str__':
print 'intercepting in-built method call '
return '%s:%s' %
(object.__getattribute__(self,'name'),object.__getattribute___(self,'price'))
else:
return self.__dict__[attr]
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<console>", line 11, in __getattr__
KeyError: '__repr__'
i am missing on a concept here. please enlighten me.