str vs unicode

Martin Pool mbp at canonical.com
Fri May 27 02:35:06 UTC 2011


One question that came up during
<https://code.launchpad.net/~mbp/bzr/220464-stale-locks/+merge/62582>:

To date we tend to use repr(o) for a debug-oriented representation of
it, and str(o) for a user-oriented representation to put in messages
etc.  This is not absolutely widely used but it does seem useful.  In
some cases it is better to have an explicit method to get the
human-readable form, but just being able to fold objects into string
templates is worthwhile.

So then the question is, should we perhaps instead move to using
__unicode__ on objects for the latter, for the sake of being a bit
safer with unicode values, and perhaps also for an easier transition
to python3?

Also, I suppose implicitly this is a chance for people to object to
the whole pattern.

Martin



More information about the bazaar mailing list