MCPcopy Index your code
hub / github.com/RustPython/RustPython / __getitem__

Method __getitem__

Lib/pathlib/__init__.py:63–72  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

61 return len(self._tail)
62
63 def __getitem__(self, idx):
64 if isinstance(idx, slice):
65 return tuple(self[i] for i in range(*idx.indices(len(self))))
66
67 if idx >= len(self) or idx < -len(self):
68 raise IndexError(idx)
69 if idx < 0:
70 idx += len(self)
71 return self._path._from_parsed_parts(self._drv, self._root,
72 self._tail[:-idx - 1])
73
74 def __repr__(self):
75 return "<{}.parents>".format(type(self._path).__name__)

Callers

nothing calls this directly

Calls 4

isinstanceFunction · 0.85
lenFunction · 0.85
indicesMethod · 0.80
_from_parsed_partsMethod · 0.80

Tested by

no test coverage detected