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

Class Squares

extra_tests/snippets/stdlib_functools.py:6–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class Squares:
7 def __init__(self, max):
8 self.max = max
9 self.sofar = []
10
11 def __len__(self):
12 return len(self.sofar)
13
14 def __getitem__(self, i):
15 if not 0 <= i < self.max:
16 raise IndexError
17 n = len(self.sofar)
18 while n <= i:
19 self.sofar.append(n * n)
20 n += 1
21 return self.sofar[i]
22
23
24def add(a, b):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected