Воробьев Сергей Юрьевич 530 ExceptionTree 12657 | Усович Алексей, 530 группа ExceptionTree 12677 | ||||
---|---|---|---|---|---|
f | 1 | class ExceptionTree: | f | 1 | class ExceptionTree: |
2 | 2 | ||||
3 | def __init__(self): | 3 | def __init__(self): | ||
n | 4 | self.exception_classes = {} | n | 4 | self.idxs = {} |
5 | 5 | ||||
n | 6 | def __call__(self, n): | n | 6 | def __call__(self, idx): |
7 | if n not in self.exception_classes: | 7 | if idx not in self.idxs: | ||
8 | if n == 1: | 8 | if idx == 1: | ||
9 | base = Exception | 9 | parent = Exception | ||
10 | else: | 10 | else: | ||
t | 11 | base = self(n // 2) | t | 11 | parent = self(idx // 2) |
12 | cls = type(f'Exception-{n}', (base,), {'n': n}) | 12 | node = type(f'Exception-{idx}', (parent,), {'n': idx}) | ||
13 | self.exception_classes[n] = cls | 13 | self.idxs[idx] = node | ||
14 | return self.exception_classes[n] | 14 | return self.idxs[idx] |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|