Issue 2599: allow field_name in format strings to default to next positional argument (e.g., "{}") (original) (raw)
Issue2599
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) * ![]() |
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) * ![]() |
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:33 | admin | set | github: 46851 |
2009-03-29 02:13:37 | r.david.murray | set | status: open -> closedversions: + Python 3.1, Python 2.7, - Python 3.0nosy: + r.david.murraymessages: + resolution: acceptedstage: resolved |
2008-04-09 21:15:17 | belopolsky | set | nosy: + belopolskymessages: + |
2008-04-08 19:51:04 | dangyogi | create |