Infinitely nested containers

Chris Angelico rosuav at
Sat Nov 22 05:50:12 CET 2014

On Sat, Nov 22, 2014 at 3:43 PM, Steven D'Aprano
<steve+comp.lang.python at> wrote:
> random832 at wrote:
>> There's no reason not to allow it with tuples, but you can't do it.
>> Mainly because doing it in a single literal would require special
>> syntax, whereas you can simply append to a list a reference to itself.
> You can't append a list to itself in a single expression, you have to create
> the list first.

It's possible to have a list directly refer to itself:

lst = []

It's not possible, with pure Python code, to create a tuple with a
reference to itself, because you have to create a tuple with a single
expression. Hence the comments about using the C API... and breaking


More information about the Python-list mailing list