[Python-checkins] cpython (2.7): Make the from_iterable() recipe more usable.
raymond.hettinger
python-checkins at python.org
Fri Dec 28 09:03:30 CET 2012
http://hg.python.org/cpython/rev/14f99221d937
changeset: 81122:14f99221d937
branch: 2.7
parent: 81117:b7a0e03bb987
user: Raymond Hettinger <python at rcn.com>
date: Fri Dec 28 00:03:30 2012 -0800
summary:
Make the from_iterable() recipe more usable.
The code isn't exactly equivalent because a classmethod would
only make sense inside a chain class, and it would need "cls"
as a first argument, and it would need to return an instance
of "chain" rather than a generator.
The updated example drops the @classmethod decorator so that
it can be used standalone: list(from_iterable(['abc', 'def']))
This should be communicate what from_iterable does.
files:
Doc/library/itertools.rst | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -106,9 +106,8 @@
.. classmethod:: chain.from_iterable(iterable)
Alternate constructor for :func:`chain`. Gets chained inputs from a
- single iterable argument that is evaluated lazily. Equivalent to::
+ single iterable argument that is evaluated lazily. Roughly equivalent to::
- @classmethod
def from_iterable(iterables):
# chain.from_iterable(['ABC', 'DEF']) --> A B C D E F
for it in iterables:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list