all Python 3deprecated in 3.9astterm
ast.ExtSlice
expressions
A deprecated node for an extended slice a[1:2, 3] from Python 3.8 and earlier. Since 3.9 such an index is an ast.Tuple in the slice field of Subscript.
Syntax
ast.ExtSlice(dims) # устарел: возвращает ast.Tuple(dims, ast.Load())
The class stays for compatibility, but the parser no longer creates it, and calling ast.ExtSlice(dims) returns ast.Tuple(dims, Load()) — isinstance(node, ast.ExtSlice) on parsed code is always False. Analysis code written for 3.8 that checked ExtSlice and Index silently skips subscripts on 3.9+: read node.slice instead, which holds a Tuple, a Slice or the index expression itself. Removal is promised for a future version, with no number.
Examples
import ast
node = ast.parse('a[1:2, 3]', mode='eval').body
print(type(node).__name__, type(node.slice).__name__) # → Subscript Tuple
print([type(x).__name__ for x in node.slice.elts]) # → ['Slice', 'Constant']
import ast
made = ast.ExtSlice([ast.Name('i')])
print(type(made).__name__, type(made.ctx).__name__) # → Tuple Load
See also
Open in the full glossarydocs.python.orgReport an inaccuracy