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

Method __getitem__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

_from_parsed_partsMethod · 0.80

Tested by

no test coverage detected