Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '(python': 0.07; 'none)': 0.09; 'received:internal': 0.09; 'python': 0.11; '23,': 0.16; 'finds': 0.16; 'itself,': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'really?': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'tuple': 0.16; 'tuple,': 0.16; 'tuple.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'print': 0.22; 'fine': 0.24; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; "d'aprano": 0.31; 'routine': 0.31; 'steven': 0.31; 'received:66': 0.35; 'list': 0.37; 'received:10': 0.37; 'nov': 0.38; 'to:addr :python-list': 0.38; 'issue': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'conversion': 0.61; 'header:Message-Id:1': 0.63; 'more': 0.64; '2014,': 0.84; 'fact.': 0.84; 'measure.': 0.84; 'remembering': 0.84; 'str.': 0.91 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=UwO20rJeFhxsovuBVQHh5qjFRf8=; b=sO42 IdK6jt3CacnVQtO2EVnqlXzTQcaJUxxKnsNGlfol5TY7AX1bNQrNYEQegVh4TYYy w3HotmYEXv/ENJBp8US+sTeJyEB5YDnucgY8coxsI5Q47xK0flX6N9wZnCkp4E8+ Zl/C5wlQ/Wl7H7eLX23XPuOFTT0SzcVlGU5G4H8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=UwO20rJeFhxsovuBVQHh5qjF Rf8=; b=aq16EQ5glF7/Nox9hIVPqIrUsTS17OSueSIewGm9IrFahkY28JIrWeSJ 1dPNbypjSQSTevKfRM9+EcQ/2JgjaAFT2DUzAiFFt2Y++NUjuHCI201BzeoqWNKX eANzcySC2IUVkO8ocUYNYItdIw+UhB3Xt+Q/+ovDSCISFyi4uS8= X-Sasl-Enc: 1rbbo4MyoeHb5zWwlRzSlV/d9OwHh7P4vowaGXtegV0V 1416724796 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-a419c8a0 In-Reply-To: <547177a5$0$12989$c3e8da3$5496439d@news.astraweb.com> References: <931d12c0-12b3-4278-a9b9-1e2c32f138b3@googlegroups.com> <87bno16nsw.fsf@elektro.pacujo.net> <54701468$0$12986$c3e8da3$5496439d@news.astraweb.com> <547177a5$0$12989$c3e8da3$5496439d@news.astraweb.com> Subject: Re: Infinitely nested containers Date: Sun, 23 Nov 2014 01:39:56 -0500 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416724802 news.xs4all.nl 2956 [2001:888:2000:d::a6]:33201 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81337 On Sun, Nov 23, 2014, at 00:59, Steven D'Aprano wrote: > >> 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. > > Really? I hadn't noticed. > > *wink* > > It's still a tuple in itself, recursively, and the tuple to str > conversion > routine still has to deal with the fact. Does it, or does it punt to the list to str routine? Anyway, on python 2.7, print and str do not work the same way for tuples. I'm remembering more about this issue now, and it was _strictly_ on print, not on str. >>> t ([[...], ([...], None)], None) >>> print(t) ([[...], ([...], None)], None) >>> str(t) '([[...], (...)], None)' Notice that print never does (...), only [...]. And if it never finds a [...]?