Infinitely nested containers

Ethan Furman ethan at stoneleaf.us
Sat Nov 22 20:50:19 CET 2014


On 11/21/2014 08:43 PM, Steven D'Aprano wrote:
> random832 at fastmail.us wrote:
>> 
>> I think I tried on at least one python version and printing the tuple
>> crashed with a recursion depth error, since it had no special protection
>> for this case the way list printing does.
> 
> It works fine now (Python 3.3).
> 
> py> L = []
> py> t = (L, None)
> py> L.append(L)
> py> L.append(t)  # For good measure.
> py> print(t)
> ([[...], (...)], None)

This is a tuple in a list in a tuple, not a tuple in a tuple.

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20141122/8c73bcc8/attachment.sig>


More information about the Python-list mailing list