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.

Author terry.reedy
Recipients terry.reedy
Date 2009-02-12.23:28:47
SpamBayes Score 4.3077675e-09
Marked as misclassified No
Message-id <1234481329.65.0.197500970463.issue5237@psf.upfronthosting.co.za>
In-reply-to
Content
3.x str.format() format strings denote replacement fields with braces
{}. Currently, replacement fields *must* contain "either the numeric
index of a positional argument, or the name of a keyword argument". [lib
ref / builtin types / sequence types / string methods /str.format()]

For simple sequential positional replacements, such as:
  "{0} is {1} {2}".format('Numbering fields', 'an annoying', 'nuisance')
the writer has to do what computers are so good at, counting, and what
was *not* required with % interpolation, where one could write more simply
  "%s is %s %s" % (('Auto-numbering', 'a convenient', 'feature')
.
Proposal: Allow field names to be omitted for all fields in a string and
then default to 0, 1, ... so one could also write 
  "{} is {} {}".format('Auto-numbering', 'a convenient', 'feature'

This proposal is currently all or nothing for simplicity of description
and presumed ease of implementation.  The patch to the doc could then be
  "If all replacement fields are left blank, then sequential indexes 0,
1, ... will be automatically inserted."
inserted after the phrase quoted above.  Mixing blank and non-blank
specs would then be an error and raise an exception.

This idea was posted today on Python-ideas thread "String formatting and
named tuple".  So far, +1 from Aahz, Raymond Hettinger, and Mathias
Panzenbock.
History
Date User Action Args
2009-02-12 23:28:49terry.reedysetrecipients: + terry.reedy
2009-02-12 23:28:49terry.reedysetmessageid: <1234481329.65.0.197500970463.issue5237@psf.upfronthosting.co.za>
2009-02-12 23:28:48terry.reedylinkissue5237 messages
2009-02-12 23:28:47terry.reedycreate