MCPcopy Index your code
hub / github.com/python/cpython / evaluate_slice_index

Function evaluate_slice_index

Lib/test/test_slice.py:14–25  ·  view source on GitHub ↗

Helper function to convert a slice argument to an integer, and raise TypeError with a suitable message on failure.

(arg)

Source from the content-addressed store, hash-verified

12
13
14def evaluate_slice_index(arg):
15 """
16 Helper function to convert a slice argument to an integer, and raise
17 TypeError with a suitable message on failure.
18
19 """
20 if hasattr(arg, '__index__'):
21 return operator.index(arg)
22 else:
23 raise TypeError(
24 "slice indices must be integers or "
25 "None or have an __index__ method")
26
27def slice_indices(slice, length):
28 """

Callers 1

slice_indicesFunction · 0.85

Calls 1

indexMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…