File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -1143,17 +1143,15 @@ Formal subscription grammar
11431143.. grammar-snippet ::
11441144 :group: python-grammar
11451145
1146- subscription: `primary ` '[' `subscript ` ']'
1147- subscript: `slice ` | `tuple_slices `
1148- tuple_slices: ','.(`slice ` | `starred_expression `)+ [',']
1149- slice: `proper_slice ` | `assignment_expression `
1150- proper_slice: [`expression `] ":" [`expression `] [ ":" [`expression `] ]
1151-
1152- There is a semantic difference between the alternatives for *subscript *.
1153- If *subscript * contains only one unstarred *slice * without a trailing comma,
1154- it will evaluate to the value of that *slice *.
1155- Otherwise, *subscript * will evaluate to a :class: `tuple ` containing
1156- the items of *tuple_slices *.
1146+ subscription: `primary ` '[' `subscript ` ']'
1147+ subscript: `single_subscript ` | `tuple_subscript `
1148+ single_subscript: `proper_slice ` | `assignment_expression `
1149+ proper_slice: [`expression `] ":" [`expression `] [ ":" [`expression `] ]
1150+ tuple_subscript: ','.(`single_subscript ` | `starred_expression `)+ [',']
1151+
1152+ Recall that the ``| `` operator :ref: `denotes *ordered choice* <notation >`.
1153+ Specifically, in :token: `!subscript `, if both alternatives of would match, the
1154+ first (:token: `!single_subscript `) has priority.
11571155
11581156.. index ::
11591157 pair: object; callable
You can’t perform that action at this time.
0 commit comments