diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-10-06 14:11:45 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-10-06 14:11:45 (GMT) |
commit | 7d14015e629da702f17d5e0ab616c15c8145e771 (patch) | |
tree | c4905ff89a2d5c64486a6ffdeddc5ae74cf848ae /Lib/lib2to3/pytree.py | |
parent | c018f57186bed05a129a0eda5d9ae11d94da5189 (diff) | |
download | cpython-7d14015e629da702f17d5e0ab616c15c8145e771.zip cpython-7d14015e629da702f17d5e0ab616c15c8145e771.tar.gz cpython-7d14015e629da702f17d5e0ab616c15c8145e771.tar.bz2 |
Issue #16120: Use |yield from| in stdlib.
Patch by Berker Peksag.
Diffstat (limited to 'Lib/lib2to3/pytree.py')
-rw-r--r-- | Lib/lib2to3/pytree.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py index 17cbf0a..c4a1be3 100644 --- a/Lib/lib2to3/pytree.py +++ b/Lib/lib2to3/pytree.py @@ -194,8 +194,7 @@ class Base(object): def leaves(self): for child in self.children: - for x in child.leaves(): - yield x + yield from child.leaves() def depth(self): if self.parent is None: @@ -274,16 +273,14 @@ class Node(Base): def post_order(self): """Return a post-order iterator for the tree.""" for child in self.children: - for node in child.post_order(): - yield node + yield from child.post_order() yield self def pre_order(self): """Return a pre-order iterator for the tree.""" yield self for child in self.children: - for node in child.pre_order(): - yield node + yield from child.pre_order() def _prefix_getter(self): """ |