PyDocs

Nav

Python Runtime Services

slice

  • slice(stop, /)
  • slice(start, stop, step=None, /)
slice(stop)
slice(start, stop[, step])

Create a slice object.

This is used for extended slicing (e.g. a[0:10:2]).
Changed in 3.12
  • 3.12: Slice objects are now hashable (provided start, stop, and step are hashable).
Members of slice

i

indices
Assuming a sequence of length len, calculate the start and stop indices, and the stride length of the extended slice described by S.

s

start
These read-only attributes are set to the argument values (or their default).
step
These read-only attributes are set to the argument values (or their default).
stop
These read-only attributes are set to the argument values (or their default).
0 Examples
No examples for builtins/slice.
See Also
No see-alsos for builtins/slice
0 Notes
No notes for slice