Inner workings of this Python feature: Can a Python data structure reference itself?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun May 3 07:10:39 EDT 2015


On Sun, 3 May 2015 09:17 am, Terry Reedy wrote:

> I believe that there was a time when printing a recursive structure hit
> the recursion limit like your flatten did. But I will not reload 1.5 to
> check.

No, that was already fixed by 1.5:

[steve at ando ~]$ python1.5
Python 1.5.2 (#1, Aug 27 2012, 09:09:18)  [GCC 4.1.2 20080704 (Red Hat
4.1.2-52)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> L = []
>>> L.append(L)
>>> print L
[[...]]


I'm not sure when it was fixed -- possibly 1.4?



-- 
Steven




More information about the Python-list mailing list