[Python-Dev] Unicode as argument for 8-bit format strings
M.-A. Lemburg
mal@lemburg.com
Fri, 07 Apr 2000 23:03:31 +0200
Guido van Rossum wrote:
>
> > No problem... :-) Its a simple fix: once %s in an 8-bit string
> > sees a Unicode object it will stop processing the string and
> > restart using the unicode formatting algorithm.
>
> But the earlier items might already have incurred side effects
> (e.g. when rendering user code)... Unless you save all the strings
> you got for reuse, which seems a pain as well.
Oh well... I don't think it's worth getting this 100% right. We'd
need quite a lot of code to store the intermediate results
and then have them reused during the Unicode %-formatting -- just
to catch the few cases where str(obj) does have side-effects:
the code would have to pass the partially rendered string
pasted together with the remaining format string to
the Unicode coercion mechanism and then fiddle the arguments right.
Which side-effects are you thinking about here ? Perhaps it
would be better to simply raise an exception in case '%s'
meets Unicode.
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/