ch17: update from book draft

This commit is contained in:
Luciano Ramalho
2020-02-18 23:45:05 -03:00
parent 70650841b3
commit aa868e8f75
35 changed files with 788 additions and 31 deletions

View File

@@ -0,0 +1,10 @@
def tree(cls):
yield cls.__name__, 0 # <1>
for sub_cls in cls.__subclasses__(): # <2>
yield sub_cls.__name__, 1 # <3>
if __name__ == '__main__':
for cls_name, level in tree(BaseException):
indent = ' ' * 4 * level # <4>
print(f'{indent}{cls_name}')