__str__ and __unicode__ seem to behave differently. A __str__ overwrite in a str subclass is used when calling str(), a __unicode__ overwrite in a unicode subclass is *not* used when calling unicode():
------------------------------- class str2(str): def __str__(self): return "foo"
x = str2("bar") print str(x)
class unicode2(unicode): def __unicode__(self): return u"foo"
x = unicode2(u"bar") print unicode(x) -------------------------------
This outputs: foo bar
IMHO this should be fixed so that __unicode__() is used in the second case too.
Bye, Walter Dörwald
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com