__str__ vs. __repr__
Just van Rossum
just at letterror.com
Fri Nov 5 12:44:52 CET 1999
At 2:04 AM -0500 11/5/99, Tim Peters wrote:
>rendering Python useless to grownups. How does Python's Unicode story
>relate to this? Displaying a Unicode string as a pile of \uxxxx (whatever)
>escapes defeats the whole purpose of Unicode. Ditto displaying it in UTF-7.
>OTOH, for some number of years to come it will be a rare display device that
>*won't* treat Unicode 16-bit values (whether or not UTF-8 encoded) as a pile
>of 8-bit control codes.
[ ... ]
>Until Unicode takes over the world, there's nothing you can do other than
>tell users the truth: "most of" printable 7-bit ASCII displays the same way
>across the world, but outside of that *all* bets are off. It will vary by
>all of OS, display device, displaying program, and user configuration
As a step towards a Unicode-savvy Python, would it be an idea to define
Unicode versions of repr(), str(), ob.__repr__() and ob.__str__()?
'print' could then use these if it knows stdout is a Unicode-savvy output
More information about the Python-list