Steven D'Aprano added the comment:

I don't think that this behaviour is desirable, certainly not by default. If I 
write "{1} {0}".format('one') that's clearly a programming error and I should 
get an exception. Chaining a second .format method call afterwards does not 
make the first one any less of a mistake.

I think that there may be a good argument to be made for a safe_format with 
*named* arguments, like string.Template, but not positional arguments. But that 
would require some discussion, to decide on the correct behaviour. And why not 
use string.Template in the first place, or make the chained calls a single call?

"{1} {0}".format('one', 'two')

is clearly the most obvious way to do it. A slightly less obvious way:

"{{}} {}".format('one').format('two')

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24549>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to