小编pon*_*der的帖子

exec `repr()` 时超出了最大递归深度

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.

我的英语很差,希望你们能理解这些。非常感谢!

python recursion repr

1
推荐指数
1
解决办法
1090
查看次数

标签 统计

python ×1

recursion ×1

repr ×1