[issue5237] Allow auto-numbered replacement fields in str.format() strings

Guido van Rossum report at bugs.python.org
Sat Mar 14 03:44:27 CET 2009


Guido van Rossum <guido at python.org> added the comment:

> About '{:{fmt}}' and other wacky combinations, like '{.__doc__}':
>
> It's much easier and cleaner in the code to allow these cases than it
> would be to disallow them. And I rather like the '{:{fmt}}' example!
>
> I suggest leaving them in. They might be useful, and it makes the
> implementation cleaner. I think it will be easier to document, as well.
> There are no special cases to describe: If the field name is omitted,
> it's auto-numbered with a sequential index number. You can't mix
> auto-numbering and manual specification of indexes.

OK, if allowing it is simpler, I'm all for allowing it! (I thought it
would be extra work. Shame on me for not looking at the code. :-)

> As for string.Formatter, I agree we should leave it alone. I'd be
> surprised if anyone is actually using it, anyway. But I'd love to hear
> otherwise.

OK.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5237>
_______________________________________


More information about the Python-bugs-list mailing list