[Python-Dev] summary of transitioning from % to {} formatting
Barry Warsaw
barry at python.org
Sat Oct 3 18:30:59 CEST 2009
On Oct 3, 2009, at 11:41 AM, Steven Bethard wrote:
> I thought it might be useful for those who don't have time to read a
> million posts to have a summary of what's happened in the formatting
> discussion.
>
> The basic problem is that many APIs in the standard library and
> elsewhere support only %-formatting and not {}-formatting, e.g.
> logging.Formatter accepts::
> logging.Formatter(fmt="%(asctime)s - %(name)s")
> but not::
> logging.Formatter(fmt="{asctime} - {name}")
I'd like to at least keep in mind $-strings. I don't have any
experience with {}-strings w.r.t. i18n translators, but I'm very
confident that $-strings are better for translators than %-strings.
OT1H {}-strings don't suffer from the #1 problem of %-strings: leaving
off the trailing 's' or whatever. OTOH, I suspect that $-strings are
still easier for the simple substitution case; for example, it's
conceivable that translators may forget the trailing close brace.
Since we're likely to have multiple formatting styles at least for
Python 3's lifetime, I'd like any solution we come up with to at least
not preclude the use of $-strings.
I also don't think this is a case of anti-TOOWTDI. For most
situations {}-strings are great (IMO), but in the specific translation
domain, I suspect $-strings are still better.
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 832 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-dev/attachments/20091003/11371b26/attachment.pgp>
More information about the Python-Dev
mailing list