[Python-Dev] transitioning from % to {} formatting (original) (raw)

Barry Scott barry at barrys-emacs.org
Sun Oct 4 14:10:57 CEST 2009


On 1 Oct 2009, at 10:37, M.-A. Lemburg wrote:

Eric Smith wrote:

Martin v. Löwis wrote:

Steven Bethard wrote:

There's a lot of code already out there (in the standard library and other places) that uses %-style formatting, when in Python 3.0 we should be encouraging {}-style formatting.

I don't agree that we should do that. I see nothing wrong with using % substitution. I agree with Martin. Both approaches have their ups and downs, but forcing users to move from %-formatting to .format()-formatting will just frustrate them: having to convert several thousand such (working) uses in their code with absolutely no benefit simply doesn't look like a good way to spend your time.

I agree you cannot force the move to {} format. There are programs that expose the %(name)s in user interfaces for customisation.

In addition to the code changes, such a move would also render existing translations of the %-formatted string templates useless.

Speaking of translation support has xgettext been updated to support {}? It is a life saver to have xgettext report that "This %s and %s" is not translatable.

Barry

-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20091004/95c7fd51/attachment.htm>



More information about the Python-Dev mailing list