On Wed, Apr 9, 2008 at 6:30 PM, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 09, 2008 at 09:20:56AM -0700, Guido van Rossum wrote: > > We > > already have repr() if you want unambiguous output; str() is for > > pretty output. > > BTW, does Python 3000 fix the problem that str(container) calls repr() > instead of str() for elements in the container? > No, because there is no sensible way to fix it. If a container defines __str__, it can do whatever it wants with items inside itself. If the container doesn't define __str__ (or defines it as an alias to __repr__), then __repr__ will be used, and the only sensible thing to do is call repr() on the elements inside it. If you want containers to have a 'prettier' format when passed to str(), give them a __str__ that does the pretty thing. Me, I don't see the point of having a 'pretty' format for lists that is ambiguous. If I want to print a list, 'repr' does what I expect. Or, I loop over the list and print each element how I expect it to print. I don't see the value in str(['1', 1, '1, [1]', '1]', '\n[1']) giving hard to understand output. -- Thomas Wouters <[EMAIL PROTECTED]> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com