keyerror '__repr__'
vijay shanker
vshanker.88 at gmail.com
Sat Aug 4 10:48:07 EDT 2012
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]
>>>b = book('the tempest',234)
>>>b
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.
More information about the Python-list
mailing list