summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2012-10-01 22:34:31 (GMT)
committerPhilip Jenvey <pjenvey@underboss.org>2012-10-01 22:34:31 (GMT)
commitfd0d3e5d25cf9dcb751a329cf390388e0dbd8da2 (patch)
tree2a0f83ce2ce3a894d27a6330ecb731bb0fc6fc76 /Lib
parent8bfcf51b5d0ca5a0bbd7045c318f5aa31e5f7de8 (diff)
downloadcpython-fd0d3e5d25cf9dcb751a329cf390388e0dbd8da2.zip
cpython-fd0d3e5d25cf9dcb751a329cf390388e0dbd8da2.tar.gz
cpython-fd0d3e5d25cf9dcb751a329cf390388e0dbd8da2.tar.bz2
more yield from
patch by Serhiy Storchaka
Diffstat (limited to 'Lib')
-rw-r--r--Lib/http/cookiejar.py3
-rw-r--r--Lib/json/encoder.py15
-rw-r--r--Lib/xml/etree/ElementPath.py6
-rw-r--r--Lib/xml/etree/ElementTree.py6
4 files changed, 10 insertions, 20 deletions
diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index 901e762..a77dc3f 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -1193,8 +1193,7 @@ def deepvalues(mapping):
pass
else:
mapping = True
- for subobj in deepvalues(obj):
- yield subobj
+ yield from deepvalues(obj)
if not mapping:
yield obj
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index 75b7f49..ba57c2c 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -305,8 +305,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
chunks = _iterencode_dict(value, _current_indent_level)
else:
chunks = _iterencode(value, _current_indent_level)
- for chunk in chunks:
- yield chunk
+ yield from chunks
if newline_indent is not None:
_current_indent_level -= 1
yield '\n' + _indent * _current_indent_level
@@ -381,8 +380,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
chunks = _iterencode_dict(value, _current_indent_level)
else:
chunks = _iterencode(value, _current_indent_level)
- for chunk in chunks:
- yield chunk
+ yield from chunks
if newline_indent is not None:
_current_indent_level -= 1
yield '\n' + _indent * _current_indent_level
@@ -404,11 +402,9 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
elif isinstance(o, float):
yield _floatstr(o)
elif isinstance(o, (list, tuple)):
- for chunk in _iterencode_list(o, _current_indent_level):
- yield chunk
+ yield from _iterencode_list(o, _current_indent_level)
elif isinstance(o, dict):
- for chunk in _iterencode_dict(o, _current_indent_level):
- yield chunk
+ yield from _iterencode_dict(o, _current_indent_level)
else:
if markers is not None:
markerid = id(o)
@@ -416,8 +412,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
raise ValueError("Circular reference detected")
markers[markerid] = o
o = _default(o)
- for chunk in _iterencode(o, _current_indent_level):
- yield chunk
+ yield from _iterencode(o, _current_indent_level)
if markers is not None:
del markers[markerid]
return _iterencode
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index 52e65f0..341dac0 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -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):
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index b9d8df6..c199b17 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -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