Author terry.reedy
Recipients LambertDW, eric.smith, ezio.melotti, gvanrossum, mark.dickinson, ncoghlan, orsenthil, pitrou, terry.reedy
Date 2009-04-21.00:11:56
SpamBayes Score 2.22824e-10
Marked as misclassified No
Message-id <>
Suggested doc change for
LibRef / StringServices / string.... / Format String Syntax

1. In the grammar box, replace the field_name line with
field_name ::=  arg_name ("." attribute_name | "[" element_index "]")*
arg_name   ::= (identifier | integer)? 
The current text ambiguously uses "field_name" for both 'field_name' and
'arg_name'.  I found explaining the rule for blank arg_names in
field_names easier and clearer with two separate unambiguous terms.

Note: 'element_index' should be linked to its definition just as, for
instance, 'attribute_name' is.  Currently it is not.

2. Revise the next two paragraphs as follows (using * to indicate
grammar-term italics as in the current text -- except *all* is just for
In less formal terms, the replacement field starts with a *field_name*
that specifies the object whose value is to be formatted and inserted
into the output instead of the replacement field.  The *field_name* is
optionally followed by a *conversion* field, which is preceded by an
exclamation point '!', and a *format_spec*, which is preceded by a colon
':'.  These specify a non-default format for the replacement value.

The *field_name* itself begins with an *arg_name* that is either a
number or a keyword. If it’s a number, it refers to a positional
argument of the str.format() method, and if it’s a keyword it refers to
a named keyword argument. If the numerical arg_names in a format string
are 0, 1, 2, ... in sequence, they can *all* be omitted (not just some)
and the numbers 0, 1, 2, ... will be automatically inserted in order. 
The *arg_name* can be followed by any number of index or attribute
expressions. An expression of the form '.name' selects the named
attribute using getattr(), while an expression of the form '[index]'
does an index lookup using __getitem__().
Note: getattr and __getitem__ should be left linked as in the current text.

3. In the following examples, add
"From {} to {}"      # Same as "From {0] to {1}"
Date User Action Args
2009-04-21 00:12:01terry.reedysetrecipients: + terry.reedy, gvanrossum, mark.dickinson, ncoghlan, orsenthil, pitrou, eric.smith, LambertDW, ezio.melotti
2009-04-21 00:12:00terry.reedysetmessageid: <>
2009-04-21 00:11:58terry.reedylinkissue5237 messages
2009-04-21 00:11:57terry.reedycreate