class A(object):
def xx(self):
return 'xx'
class B(A):
def __repr__(self):
return 'ss%s' % self.xx
b = B()
print repr(b)
Run Code Online (Sandbox Code Playgroud)
当我写__repr__方法时,我忘记调用self.xx.
为什么这些代码会导致RuntimeError: maximum recursion depth exceeded while getting the str of an object.
我的英语很差,希望你们能理解这些。非常感谢!