This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: allow field_name in format strings to default to next positional argument (e.g., "{}")
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: belopolsky, dangyogi, r.david.murray
Priority: normal Keywords:

Created on 2008-04-08 19:51 by dangyogi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg65210 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2008-04-08 19:51
Being forced to number the arguments when using positional arguments in
a format string is difficult to maintain.  Adding an argument to the
format string either requires renumbering all subsequent arguments, or
using an out of sequence number such that the order of the format()
arguments no longer matches the order of the "{...}" arguments.  Making
the integer optional would solve this.  Thus, "{}" would be like the old
"%s" where it was far easier to add %s arguments in the middle of the
format string.

Python 3.0a3
msg65264 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2008-04-09 21:15
Omitting the ordinals from {} format units will present a problem with
internationalization because the arguments may need to be rendered in
different order in different languages.  This is a frequent problem with
the % formats and it is a good thing that the new format requires
explicit enumeration.  If your argument list grows to the big enough
size that renumbering presents a problem, you should consider using
named rather than positional arguments.

This type of changes should be discussed on python-ideas list first.
msg84361 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-03-29 02:13
This was proposed on python-ideas, discussed, approved, and implemented
for 2.7 and 3.1.

Note that although this wasn't discussed, the internationalization issue
is answered by the fact that when internationalizing, you are rewriting
the string.  At that time if you need a different order of the
subsitutions you can specify it, so requiring non-default numbering in
the original string doesn't really buy you anything for
internationalization.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46851
2009-03-29 02:13:37r.david.murraysetstatus: open -> closed

versions: + Python 3.1, Python 2.7, - Python 3.0
nosy: + r.david.murray

messages: + msg84361
resolution: accepted
stage: resolved
2008-04-09 21:15:17belopolskysetnosy: + belopolsky
messages: + msg65264
2008-04-08 19:51:04dangyogicreate