"%s" vs unicode

Steve Holden sholden at holdenweb.com
Tue Jan 7 19:34:34 EST 2003


"Robin Becker" <robin at jessikat.fsnet.co.uk> wrote in message
news:JiqD$KAGb2G+Ewyl at jessikat.fsnet.co.uk...
> In article <m3u1gkwvui.fsf at mira.informatik.hu-berlin.de>, Martin v.
> Löwis <martin at v.loewis.de> writes
> >Robin Becker <robin at jessikat.fsnet.co.uk> writes:
> >
> >> That was considered harmful (although I disagreed) so why is this
> >> implicit conversion allowed?
> >
> >It follows the general principle that, when combining byte strings and
> >Unicode strings, the byte string will be converted to Unicode, not
> >vice versa.
> >
> >Regards,
> >Martin
> >
> but the general principal here is that %s converts things to strings.
> What is general about breaking this?


Well, there's also a widening principle that you seem to be ignoring. In the
same way that int+float gives float, and float*complex gives complex, so any
string operation involving a Unicode operation gives a Unicode result.

Otherwise what would you have Python do with non-translatable Unicode
characters it has to handle in a %s substitution? Give an ordinal value
error?

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Bring your musical instrument to PyCon!    http://www.python.org/pycon/
-----------------------------------------------------------------------







More information about the Python-list mailing list