【发布时间】:2016-11-10 16:22:57
【问题描述】:
class A(object):
def xx(self):
return 'xx'
class B(A):
def __repr__(self):
return 'ss%s' % self.xx
b = B()
print repr(b)
我写__repr__方法的时候忘记调用self.xx了。
为什么这些代码会导致RuntimeError: maximum recursion depth exceeded while getting the str of an object。
我的英语很差,希望你们能理解这些。非常感谢!
【问题讨论】:
-
@skyking:是的,OP 意识到了这一点。他们在问题中声明他们忘了打电话给
self.xx。