MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / __getitem__

Method __getitem__

example_code/item_057.py:96–100  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

94 yield from self.right._traverse()
95
96 def __getitem__(self, index):
97 for i, item in enumerate(self._traverse()):
98 if i == index:
99 return item.value
100 raise IndexError(f"Index {index} is out of range")
101
102
103print("Example 7")

Callers 1

item_057.pyFile · 0.45

Calls 1

_traverseMethod · 0.95

Tested by

no test coverage detected