Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81337

Re: Infinitely nested containers

From random832@fastmail.us
References (1 earlier) <87bno16nsw.fsf@elektro.pacujo.net> <mailman.16114.1416591558.18130.python-list@python.org> <54701468$0$12986$c3e8da3$5496439d@news.astraweb.com> <mailman.16142.1416685847.18130.python-list@python.org> <547177a5$0$12989$c3e8da3$5496439d@news.astraweb.com>
Subject Re: Infinitely nested containers
Date 2014-11-23 01:39 -0500
Newsgroups comp.lang.python
Message-ID <mailman.16163.1416724802.18130.python-list@python.org> (permalink)

Show all headers | View raw



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
[...]?

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Infinitely nested containers Gill Shen <gillarete@gmail.com> - 2014-11-20 21:54 -0800
  Re: Infinitely nested containers Marko Rauhamaa <marko@pacujo.net> - 2014-11-21 09:00 +0200
    Re: Infinitely nested containers random832@fastmail.us - 2014-11-21 12:39 -0500
      Re: Infinitely nested containers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-22 15:43 +1100
        Re: Infinitely nested containers Chris Angelico <rosuav@gmail.com> - 2014-11-22 15:50 +1100
          Re: Infinitely nested containers Rustom Mody <rustompmody@gmail.com> - 2014-11-21 21:02 -0800
            Re: Infinitely nested containers Chris Angelico <rosuav@gmail.com> - 2014-11-22 16:09 +1100
              Re: Infinitely nested containers Rustom Mody <rustompmody@gmail.com> - 2014-11-21 22:03 -0800
        Re: Infinitely nested containers Ethan Furman <ethan@stoneleaf.us> - 2014-11-22 11:50 -0800
          Re: Infinitely nested containers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-23 16:59 +1100
            Re: Infinitely nested containers random832@fastmail.us - 2014-11-23 01:39 -0500
    Re: Infinitely nested containers Chris Angelico <rosuav@gmail.com> - 2014-11-22 04:47 +1100
    Re: Infinitely nested containers random832@fastmail.us - 2014-11-21 12:50 -0500
    Re: Infinitely nested containers Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-21 11:37 -0700
    Re: Infinitely nested containers Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-11-21 13:30 -0600
    Re: Infinitely nested containers Terry Reedy <tjreedy@udel.edu> - 2014-11-22 16:57 -0500
  Re: Infinitely nested containers Chris Angelico <rosuav@gmail.com> - 2014-11-21 18:03 +1100
  Re: Infinitely nested containers Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-21 10:13 -0700

csiph-web