Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17426 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2011-12-17 22:08 -0500 |
| Last post | 2011-12-17 22:08 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: root[:]=[root,root] Terry Reedy <tjreedy@udel.edu> - 2011-12-17 22:08 -0500
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-12-17 22:08 -0500 |
| Subject | Re: root[:]=[root,root] |
| Message-ID | <mailman.3776.1324177728.27778.python-list@python.org> |
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
Back to top | Article view | comp.lang.python
csiph-web