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


Groups > comp.lang.python > #100395

Re: Weird list conversion

From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Weird list conversion
Date 2015-12-14 08:09 +1100
Message-ID <mailman.221.1450040994.12405.python-list@python.org> (permalink)
References <5926ced0-5b86-41f2-81e8-55cc6f71b78c@googlegroups.com> <mailman.216.1450036662.12405.python-list@python.org> <3193bf38-82c3-4538-b500-5e23158898e6@googlegroups.com> <566DD4E0.50804@lucidity.plus.com> <566DD5A4.9040905@lucidity.plus.com>

Show all headers | View raw


On Mon, Dec 14, 2015 at 7:31 AM, Erik <python@lucidity.plus.com> wrote:
> On 13/12/15 20:28, Erik wrote:
>>
>> When you call "print", then the list class's __repr__() method is called
>> which in turn calls the contained objects' __repr__() methods in turn
>
>
> I mean the __str__() method, not __repr__() in this case - however, the
> answer is otherwise the same.

It actually makes no difference; lists don't have __str__, and fall
back on object.__str__, which returns self.__repr__(). Inside
list.__repr__, the contained objects' reprs are combined. With lists,
you always get the repr. :)

ChrisA

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


Thread

Weird list conversion high5storage@gmail.com - 2015-12-13 11:45 -0800
  Re: Weird list conversion Laura Creighton <lac@openend.se> - 2015-12-13 20:57 +0100
    Re: Weird list conversion KP <kai.peters@gmail.com> - 2015-12-13 12:05 -0800
      Re: Weird list conversion Erik <python@lucidity.plus.com> - 2015-12-13 20:28 +0000
      Re: Weird list conversion Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-13 13:28 -0700
      Re: Weird list conversion Erik <python@lucidity.plus.com> - 2015-12-13 20:31 +0000
      Re: Weird list conversion Larry Hudson <orgnut@yahoo.com> - 2015-12-13 12:42 -0800
      Re: Weird list conversion Chris Angelico <rosuav@gmail.com> - 2015-12-14 08:09 +1100
  Re: Weird list conversion Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-13 12:59 -0700

csiph-web