【发布时间】:2015-12-15 03:55:15
【问题描述】:
阅读 Guido 的博客“Tail Recursion Elimination”后,我在玩耍时遇到了这个错误。
我很好奇嵌套字典是否存在非递归限制,并且我确实收到了一条错误消息,但只是在非常特定的情况下使用 IPython 控制台。
如果我降低 xrange(100 个作品),则没有错误。这里发生了什么?
thing = {}
thing2 = thing
for x in xrange(500):
thing2[x] = {}
thing2 = thing2[x]
thing
输出:
Traceback (most recent call last):
File "<ipython-input-83-0b6d347b01d4>", line 1, in <module>
thing
File "C:\Python27\lib\site-packages\IPython\core\displayhook.py", line 255, in __call__
self.log_output(format_dict)
File "C:\Python27\lib\site-packages\IPython\core\displayhook.py", line 227, in log_output
format_dict['text/plain']
KeyError: 'text/plain'
repr(thing)
Out[84]: '{0: {1: {2: {3: {4: ....{497: {498: {499: {}}}}}}}}'
【问题讨论】:
-
无法重现同样的错误。
-
这(可能)是 IPython 如何将数据输出到 HTML 页面的问题。对于它的价值,它在 Python 3.x 和 IPython-4.04 上也失败了,错误为
maximum recursion depth exceeded while calling a Python object。
标签: python python-2.7 ipython spyder