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