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