diff options
author | Raymond Hettinger <python@rcn.com> | 2008-01-22 23:25:35 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-01-22 23:25:35 (GMT) |
commit | 1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce (patch) | |
tree | 365fcd0e0d95e4ff612ca7184d441e6184f8b203 /Doc | |
parent | 86def6cb2b8d6d8c7f239795fa7af57c97a5890d (diff) | |
download | cpython-1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce.zip cpython-1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce.tar.gz cpython-1dfde1ddc0e1980d67bd19e187252d4e52b4f7ce.tar.bz2 |
Replace map(None, *iterables) with zip(*iterables).
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/functions.rst | 12 | ||||
-rw-r--r-- | Doc/library/itertools.rst | 16 |
2 files changed, 5 insertions, 23 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 08ab140..5635c70 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -648,17 +648,7 @@ available. They are listed here in alphabetical order. Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterable* arguments are passed, *function* must take that many arguments and is applied to the items from all - iterables in parallel. If one iterable is shorter than another it is assumed - to be extended with ``None`` items. If *function* is ``None``, the identity - function is assumed; if there are multiple arguments, :func:`map` returns a - list consisting of tuples containing the corresponding items from all - iterables (a kind of transpose operation). The *iterable* arguments may be a - sequence or any iterable object; the result is always a list. - - Note that for only one *iterable* argument, ``map(function, iterable)`` is - equivalent to the generator expression ``(function(item) for item in - iterable)`` if *function* is not ``None``. - + iterables in parallel. .. function:: max(iterable[, args...], *[, key]) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index ca2b1ff..1b5ff81 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -204,21 +204,13 @@ loops that truncate the stream. .. function:: imap(function, *iterables) Make an iterator that computes the function using arguments from each of the - iterables. If *function* is set to ``None``, then :func:`imap` returns the - arguments as a tuple. Like :func:`map` but stops when the shortest iterable is - exhausted instead of filling in ``None`` for shorter iterables. The reason for - the difference is that infinite iterator arguments are typically an error for - :func:`map` (because the output is fully evaluated) but represent a common and - useful way of supplying arguments to :func:`imap`. Equivalent to:: + iterables. Equivalent to:: def imap(function, *iterables): - iterables = map(iter, iterables) + iterables = [iter(it) for it in iterables) while True: - args = [next(i) for i in iterables] - if function is None: - yield tuple(args) - else: - yield function(*args) + args = [next(it) for it in iterables] + yield function(*args) .. function:: islice(iterable, [start,] stop [, step]) |