[Python-Dev] Re: [Patches] Unicode Patch Set 2000-04-10
Mon, 10 Apr 2000 12:55:50 +0200
Greg Stein wrote:
> On Mon, 10 Apr 2000, M.-A. Lemburg wrote:
> > The attached patch includes the following fixes and additions:
> > * '...%s...' % u"abc" now coerces to Unicode just like
> > string methods. Care is taken not to reevaluate already formatted
> > arguments -- only the first Unicode object appearing in the
> > argument mapping is looked up twice. Added test cases for
> > this to test_unicode.py.
> I missed a chance to bring this up on the first round of discussion, but
> is this really the right thing to do? We never coerce the string on the
> left based on operands. For example: if the operands are class instances,
> we call __str__ -- we don't call __coerce__.
> It seems a bit weird to magically revise the left operand.
> In many cases, a Unicode used as a string is used as a UTF-8 value. Why is
> that different in this case? Seems like a wierd special case.
It's not a special case: % works just like a method call
and all string methods auto-coerce to Unicode in case a
Unicode object is found among the arguments.
Python Pages: http://www.lemburg.com/python/