str vs unicode

Andrew Bennetts andrew.bennetts at canonical.com
Fri May 27 10:04:04 UTC 2011


John Arbash Meinel wrote:
> On 05/27/2011 05:19 AM, Robert Collins wrote:
[…]
> > Doesn't python3 delete __unicode__ ? In the spirit of having no
> > compatiblity concerns, after all :)
> > 
> > -Rob
> > 
> 
> It deleted __unicode__ because __str__ *is* __unicode__.

Right.  I think Rob's issue is how to write code that is simultaneously
compatible with 2 and 3 with no translation step.  In that case I
suppose __unicode__ == __str__ (or vice versa?) is probably close to
close enough.  IIRC you can actually return unicode from __str__ in
Python 2 (probably due to the pervasive str/unicode confusion there).

-Andrew.



More information about the bazaar mailing list