On 12/16/2011 9:40 PM, YAN HUA wrote:
Hi,all. Could anybody tell how this code works?
>>> root = [None, None]
>>> root[:] = [root, root]
>>> root
[[...], [...]]
>>> root[0]
[[...], [...]]
>>> root[0][0][1][1][0][0][0][1][1]
[[...], [...]]
A simpler example:
>>> l = []
>>> l.append(l)
>>> l
[[...]]
Python is (now) smart enough to recognize a recursive list and print
'...' instead of going into an infinite loop printing '['s (as it once
did, I believe).
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list