MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / tree

Function tree

17-it-generator/tree/extra/drawtree.py:17–23  ·  view source on GitHub ↗
(cls, level=0, last_sibling=True)

Source from the content-addressed store, hash-verified

15
16
17def tree(cls, level=0, last_sibling=True):
18 yield cls, level, last_sibling
19 children = subclasses(cls)
20 if children:
21 last = children[-1]
22 for child in children:
23 yield from tree(child, level+1, child is last)
24
25
26def render_lines(tree_iter):

Callers 8

test_1_levelFunction · 0.90
test_2_levels_1_leafFunction · 0.90
test_3_levels_1_leafFunction · 0.90
test_4_levels_1_leafFunction · 0.90
test_2_levels_2_leavesFunction · 0.90
drawFunction · 0.90

Calls 1

subclassesFunction · 0.70

Tested by 7

test_1_levelFunction · 0.72
test_2_levels_1_leafFunction · 0.72
test_3_levels_1_leafFunction · 0.72
test_4_levels_1_leafFunction · 0.72
test_2_levels_2_leavesFunction · 0.72