class astroid.nodes.Slice(lineno: int | None, col_offset: int | None, parent: NodeNG | None, *, end_lineno: int | None, end_col_offset: int | None)[source]#

Bases: NodeNG

Class representing an ast.Slice node.

>>> import astroid
>>> node = astroid.extract_node('things[1:3]')
>>> node
<Subscript l.1 at 0x7f23b2e71f60>
>>> node.slice
<Slice l.1 at 0x7f23b2e71e80>

Get the child nodes below this node.

getattr(attrname, context: InferenceContext | None = None)[source]#
igetattr(attrname: str, context: InferenceContext | None = None) Iterator[SuccessfulInferenceResult][source]#

Infer the possible values of the given attribute on the slice.


attrname – The name of the attribute to infer.


The inferred possible values.

lower: NodeNG | None#

The lower index in the slice.

postinit(lower: NodeNG | None, upper: NodeNG | None, step: NodeNG | None) None[source]#
pytype() Literal['builtins.slice'][source]#

Get the name of the type that this node represents.


The name of the type.

step: NodeNG | None#

The step to take between indexes.

upper: NodeNG | None#

The upper index in the slice.