Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '22,': 0.09; 'append': 0.09; 'literal': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'itself.': 0.14; '4:39': 0.16; 'crashed': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'syntax,': 0.16; 'tuple': 0.16; 'tuples,': 0.16; 'followed': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'depth': 0.31; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'doing': 0.36; 'should': 0.36; 'list': 0.37; 'nov': 0.38; 'simply': 0.61; 'protection': 0.63; 'believe': 0.68; 'special': 0.74; 'whereas': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=R8Ol7EGcN0RQPDxvbaTf6dzx5bcfIeezET+/tAitwog=; b=JS22TS4oTPBahXDv0RyuOh0VeXdB8AqdhwvSkjNXQ6VpTkgT8kurPEio8wsXlyerad jaWySF+rWFeypvORsmnGNcNsIxAhvMT2NYX0DCrXzz6va0qWxOBvvL1Vf+IVTHl2ln8L TAZRqSVqIqOl5nbW2KxVfRQ3qQKWLsyfIMMUBK6Pq1cioaAyJT5tiIHI5iv6qctv3Xbd 2BRJEhIx50AvaNZ726ybdHmPAsZ11VGtM6oG6U54f5yljlnAHZOXq3rCdaHRT+tgBmvJ GoC0VTw2KgSdNou2F0ZBrzpS+dfIrslBk5g8/UV7Jii94dYLF5lIndOfsmahHTJTqovi 6KRw== MIME-Version: 1.0 X-Received: by 10.50.152.104 with SMTP id ux8mr5382492igb.14.1416592075067; Fri, 21 Nov 2014 09:47:55 -0800 (PST) In-Reply-To: <1416591555.652129.193873581.54A97BD7@webmail.messagingengine.com> References: <931d12c0-12b3-4278-a9b9-1e2c32f138b3@googlegroups.com> <87bno16nsw.fsf@elektro.pacujo.net> <1416591555.652129.193873581.54A97BD7@webmail.messagingengine.com> Date: Sat, 22 Nov 2014 04:47:55 +1100 Subject: Re: Infinitely nested containers From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416592077 news.xs4all.nl 2952 [2001:888:2000:d::a6]:50315 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81232 On Sat, Nov 22, 2014 at 4:39 AM, 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. > > 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. You can do it in C, I believe - PyTuple_New() followed by PyTuple_SetItem(x, 0, x) should do it. ChrisA