[Python-Dev] unicode inconsistency?

Neil Schemenauer nas at arctrix.com
Thu Sep 9 20:50:35 CEST 2004


On Thu, Sep 09, 2004 at 02:09:56PM -0400, Aahz wrote:
> Check the recent python-dev archives for a long and nauseating
> thread about interactions between __str__ and unicode.

Using __unicode__ doesn't help.  The core problem is that you cannot
create a class that behaves like 'unicode' in this operation without
subclassing from 'unicode'.  That violates the "duck typing" design
principle of Python.  We violate it other places, usually in the
name of efficiency, but I see no good reason in this case.

I suspect the fix will be pretty straight forward (call tp_str and
if the result is 'unicode' the produce a 'unicode' string).  Again,
is there some reason why we don't want this behavior?

  Neil


More information about the Python-Dev mailing list