Oleg Broytmann wrote:
> Do I understand it right that str(objects) calls repr() on items to
> properly quote strings? (str([1, '1']) must give "[1, '1']" as the result).
> Is it the only reason?

In the case of strings, yes. More generally, there
can be any kind of object in the list, and repr(x)
is more likely to give an unambiguous idea of what
x is than str(x) when it's embedded in a comma-
separated list.

Python has no way of guessing the most appropriate
way to display your list of objects when you use
str(), so it doesn't try. You have to tell it by
writing code to do what you want.

-- 
Greg
_______________________________________________
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

Reply via email to