[Python-Dev] unicode inconsistency?

M.-A. Lemburg mal at egenix.com
Thu Sep 9 22:54:26 CEST 2004

Neil Schemenauer wrote:
> On Thu, Sep 09, 2004 at 03:28:39PM -0400, Tim Peters wrote:
>>>   '%u' % u'\u1234'
>>>   '%u' % A()
>>That's the intent, yes.  Neil's original example would *also* "work"
>>then (because unlike PyObject_Str(), PyObject_Unicode() is happy to
>>accept a unicode result as-is from a tp_str implementation).
> No, it would not "work" the way I want.  I don't want to force
> things to unicode strings unless necessary.

Unicode always causes coercion towards Unicode, just like floats
always cause coercion towards floats. Nothing's going to
change at that end.

Note that your examples do work with %s if the format
string itself is Unicode, so in P3k, you'll no longer have
these problems.

Since there must be a reason why you have a __str__ method
that returns Unicode, I'd suggest you make the format string
itself a Unicode string as well :-)

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Sep 09 2004)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the Python-Dev mailing list