f | class ExceptionTree: | f | class ExceptionTree: |
| | | |
| def __init__(self): | | def __init__(self): |
| self.exceptions = {1: type('Exception1', (Exception,), {'n': 1}) | | self.exceptions = {1: type('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 // 2 | t | parent_n = n // 2 |
| if parent not in self.exceptions: | | if parent_n not in self.exceptions: |
| self(parent) | | self(parent_n) |
| self.exceptions[n] = type(f'Exception{n}', (self.exceptions[ | | self.exceptions[n] = type(f'Exception{n}', (self.exceptions[ |
| parent],), {'n': n}) | | parent_n],), {'n': n}) |
| return self.exceptions[n] | | return self.exceptions[n] |