@@ -194,15 +194,15 @@ literal text, it can be escaped by doubling: ``{{`` and ``}}``.
194194The grammar for a replacement field is as follows:
195195
196196 .. productionlist :: sf
197- replacement_field: "{" `field_name ` ["!" `conversion `] [":" `format_spec `] "}"
197+ replacement_field: "{" [ `field_name `] ["!" `conversion `] [":" `format_spec `] "}"
198198 field_name: arg_name ("." `attribute_name ` | "[" `element_index ` "]")*
199199 arg_name: (`identifier ` | `integer `)?
200200 attribute_name: `identifier `
201201 element_index: `integer `
202202 conversion: "r" | "s" | "a"
203203 format_spec: <described in the next section>
204204
205- In less formal terms, the replacement field starts with a *field_name * that specifies
205+ In less formal terms, the replacement field can start with a *field_name * that specifies
206206the object whose value is to be formatted and inserted
207207into the output instead of the replacement field.
208208The *field_name * is optionally followed by a *conversion * field, which is
@@ -223,7 +223,7 @@ Some simple format string examples::
223223
224224 "First, thou shalt count to {0}" # References first positional argument
225225 "Bring me a {}" # Implicitly references the first positional argument
226- "From {} to {}" # Same as "From {0] to {1}"
226+ "From {} to {}" # Same as "From {0} to {1}"
227227 "My quest is {name}" # References keyword argument 'name'
228228 "Weight in tons {0.weight}" # 'weight' attribute of first positional arg
229229 "Units destroyed: {players[0]}" # First element of keyword argument 'players'.
@@ -243,6 +243,7 @@ Some examples::
243243
244244 "Harold's a clever {0!s}" # Calls str() on the argument first
245245 "Bring out the holy {name!r}" # Calls repr() on the argument first
246+ "More {!a}" # Calls ascii() on the argument first
246247
247248The *format_spec * field contains a specification of how the value should be
248249presented, including such details as field width, alignment, padding, decimal
0 commit comments