mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
parent
c018f57186
commit
7d14015e62
3 changed files with 6 additions and 12 deletions
|
|
@ -96,8 +96,7 @@ class MinNode(object):
|
|||
def leaves(self):
|
||||
"Generator that returns the leaves of the tree"
|
||||
for child in self.children:
|
||||
for x in child.leaves():
|
||||
yield x
|
||||
yield from child.leaves()
|
||||
if not self.children:
|
||||
yield self
|
||||
|
||||
|
|
@ -277,7 +276,6 @@ def rec_test(sequence, test_func):
|
|||
sub-iterables"""
|
||||
for x in sequence:
|
||||
if isinstance(x, (list, tuple)):
|
||||
for y in rec_test(x, test_func):
|
||||
yield y
|
||||
yield from rec_test(x, test_func)
|
||||
else:
|
||||
yield test_func(x)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue