[Python-Dev] Issue 6081: format string using mapping rather than kwargs

Nick Coghlan ncoghlan at gmail.com
Thu Mar 25 15:16:30 CET 2010

Eric Smith wrote:
> Considering that, maybe the best thing is to do nothing. I'll update the
> issue with this note.

I agree this slightly weakens the case for change, but it's not really
the same thing. Adding a "format_mapping" method allows an arbitrary
mapping to be used with any keyword-based format string. Crafting a
special format string in order to use an arbitrary mapping means that
the same format string can no longer be used with an ordinary keyword
based call - you have to do "format(m=dict(name=y, country=z))" instead.

Moving the decision of "how am I going to be called" to the time of
writing the format string is a bit odd.

On the other hand, the specially crafted format string does have the
virtue of travelling far more easily through any APIs that wrap the
basic format() method (since it doesn't need special treatment to make
its way through the wrapping code).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list