]> granicus.if.org Git - python/commit
Issue 5237, Allow auto-numbered replacement fields in str.format() strings.
authorEric Smith <eric@trueblade.com>
Sat, 14 Mar 2009 11:57:26 +0000 (11:57 +0000)
committerEric Smith <eric@trueblade.com>
Sat, 14 Mar 2009 11:57:26 +0000 (11:57 +0000)
commit6f42edb6821462c9ce02c6c4e2f57731b43956ad
tree22a648f118e175d637901f3575d3549e975eb445
parentfeeafff0529c8fa0b5ab6a3086464cce8fd1b3fc
Issue 5237, Allow auto-numbered replacement fields in str.format() strings.

For simple uses for str.format(), this makes the typing easier. Hopfully this
will help in the adoption of str.format().

For example:
'The {} is {}'.format('sky', 'blue')

You can mix and matcth auto-numbering and named replacement fields:
'The {} is {color}'.format('sky', color='blue')

But you can't mix and match auto-numbering and specified numbering:
'The {0} is {}'.format('sky', 'blue')
ValueError: cannot switch from manual field specification to automatic field numbering

Will port to 3.1.
Lib/test/test_str.py
Lib/test/test_unicode.py
Misc/NEWS
Objects/stringlib/string_format.h