Greg Ewing wrote: > The guideline I use is quite different: str() is for > normal program output, repr() is for debugging > output.
I think that another important difference between str() and repr() is that repr() is often used as an embedded string in other objects' representations; but str() usually is not. Thus, the string returned by repr() should not span multiple lines, and it should be easy to match up its beginning with its end. str() doesn't have these restrictions. So actually, it can sometimes be convenient to use both for debugging purposes, with repr() for a short string, suitable for embedding, and str() for a more verbose, multiline, formatted string. (Another -1 for combining them.) -Edward _______________________________________________ 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