[issue5237] Allow auto-numbered replacement fields in str.format() strings
Eric Smith
report at bugs.python.org
Sat Feb 14 11:31:08 CET 2009
Eric Smith <eric at trueblade.com> added the comment:
Okay, one last version. This one lets you use object access within the
replacement string:
>>> from auto_number_formatter_3 import formatter as _
>>> _('{} {} {}').format(3, 'pi', 3.14)
'3 pi 3.14'
>>> _('{:#b} {!r:^10} {.imag}').format(3, 'pi', 3j+1)
"0b11 'pi' 3.0"
So not it lets you add in format specifiers, conversion specifiers, and
object access. At this point the improvement of leaving out the index
numbers is less clear. I'll leave it for debate if this is useful. I
think it probably is, if only because it's easier to explain the
behavior: If you leave out the 'field name', a sequential number is
added in front of the 'replacement string' (using PEP 3101 nomenclature).
Added file: http://bugs.python.org/file13082/auto_number_formatter_3.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5237>
_______________________________________
More information about the Python-bugs-list
mailing list