On 5/26/08, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Jim Jewett wrote:
> > The problem is classes where str(x) != repr(x), and how they get > > messed up when a container holding (one of their) instances is > > printed. > This is NOT a bug, since str([1, 2, 3]) and str(list("123")) SHOULD produce > results that look different. Ideally, but it isn't that important. repr(1) and repr("1") need to be different, but if str(1) and str("1") look alike, that is acceptable. It already happens with >>> "%s %s " % (1, "1") > Calling str() internally to display the > contents of containers is a broken idea. If you are using it for precise debugging, you should use repr -- and repr should be used all the way down. If you're using str because you want (fairly) readable output, then str should be used all the way down. > The ambiguity that recursive calls > to str() would introduce would make any concerns about potential confusion > between different Unicode glyphs seem utterly inconsequential. So don't do it on repr -- do it only on str -- but always do it on str, even when str falls back to repr for a particular level of recursion. -jJ _______________________________________________ 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