Python — Russell's paradox (lists,not sets)

六月ゝ 毕业季﹏ 提交于 2019-12-04 14:49:41

There is only one object of finite size here:

You first create a list object with one element [1], and then you create a reference to that object that you call Alist. When you append Alist to "istelf", you really just append the reference to your object to the object itself. You now have a list object with two elements: 1 and a reference to itself. No infinite memory involved here.

Try this to convince yourself:

Alist = [1]
Alist.append(Alist)
Alist[1][0] = 0
Alist[0]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!