mirror of
https://github.com/python/cpython
synced 2026-09-29 10:35:30 +03:00
more yield from
patch by Serhiy Storchaka
This commit is contained in:
parent
8bfcf51b5d
commit
fd0d3e5d25
5 changed files with 22 additions and 39 deletions
|
|
@ -105,14 +105,12 @@ def prepare_child(next, token):
|
|||
def prepare_star(next, token):
|
||||
def select(context, result):
|
||||
for elem in result:
|
||||
for e in elem:
|
||||
yield e
|
||||
yield from elem
|
||||
return select
|
||||
|
||||
def prepare_self(next, token):
|
||||
def select(context, result):
|
||||
for elem in result:
|
||||
yield elem
|
||||
yield from result
|
||||
return select
|
||||
|
||||
def prepare_descendant(next, token):
|
||||
|
|
|
|||
|
|
@ -459,8 +459,7 @@ class Element:
|
|||
if tag is None or self.tag == tag:
|
||||
yield self
|
||||
for e in self._children:
|
||||
for e in e.iter(tag):
|
||||
yield e
|
||||
yield from e.iter(tag)
|
||||
|
||||
# compatibility
|
||||
def getiterator(self, tag=None):
|
||||
|
|
@ -487,8 +486,7 @@ class Element:
|
|||
if self.text:
|
||||
yield self.text
|
||||
for e in self:
|
||||
for s in e.itertext():
|
||||
yield s
|
||||
yield from e.itertext()
|
||||
if e.tail:
|
||||
yield e.tail
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue