f | class ExceptionTree: | f | class ExceptionTree: |
| | | |
| def __init__(self): | | def __init__(self): |
| self.exceptions = {1: type(f'Exception1', (Exception,), {'n': 1} | | self.exceptions = {1: type(f'Exception1', (Exception,), {'n': 1} |
| )} | | )} |
| | | |
| def __call__(self, n): | | def __call__(self, n): |
| if n not in self.exceptions: | | if n not in self.exceptions: |
t | parent_n = n // 2 | t | parent = n // 2 |
| parent_exc = self(parent_n) | | parent_exc = self(parent) |
| self.exceptions[n] = type(f'Exception{n}', (parent_exc,), {' | | self.exceptions[n] = type(f'Exception{n}', (parent_exc,), {' |
| n': n}) | | n': n}) |
| return self.exceptions[n] | | return self.exceptions[n] |