summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew/3.0.rst
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2011-08-01 21:51:34 (GMT)
committerJason R. Coombs <jaraco@jaraco.com>2011-08-01 21:51:34 (GMT)
commitdf9a5f5ecfbbdb5f2e791ee3b470e2a9db609286 (patch)
treed472dd3d0aa90bb8aa5a0a6715b1eb68a28941ee /Doc/whatsnew/3.0.rst
parent9aa20affb6603a297f0327da7e990ba2e7e2daeb (diff)
downloadcpython-df9a5f5ecfbbdb5f2e791ee3b470e2a9db609286.zip
cpython-df9a5f5ecfbbdb5f2e791ee3b470e2a9db609286.tar.gz
cpython-df9a5f5ecfbbdb5f2e791ee3b470e2a9db609286.tar.bz2
Issue #12666: Clarifying changes in map for Python 3
Diffstat (limited to 'Doc/whatsnew/3.0.rst')
-rw-r--r--Doc/whatsnew/3.0.rst10
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.0.rst b/Doc/whatsnew/3.0.rst
index 852f811..523b34e 100644
--- a/Doc/whatsnew/3.0.rst
+++ b/Doc/whatsnew/3.0.rst
@@ -154,7 +154,9 @@ Some well-known APIs no longer return lists:
:meth:`dict.itervalues` methods are no longer supported.
* :func:`map` and :func:`filter` return iterators. If you really need
- a list, a quick fix is e.g. ``list(map(...))``, but a better fix is
+ a list and the input sequences are all of equal length, a quick
+ fix is to wrap :func:`map` in :func:`list`, e.g. ``list(map(...))``,
+ but a better fix is
often to use a list comprehension (especially when the original code
uses :keyword:`lambda`), or rewriting the code so it doesn't need a
list at all. Particularly tricky is :func:`map` invoked for the
@@ -162,6 +164,12 @@ Some well-known APIs no longer return lists:
regular :keyword:`for` loop (since creating a list would just be
wasteful).
+ If the input sequences are not of equal length, :func:`map` will
+ stop at the termination of the shortest of the sequences. For full
+ compatibility with `map` from Python 2.x, also wrap the sequences in
+ :func:`itertools.zip_longest`, e.g. ``map(func, *sequences)`` becomes
+ ``list(map(func, itertools.zip_longest(*sequences)))``.
+
* :func:`range` now behaves like :func:`xrange` used to behave, except
it works with values of arbitrary size. The latter no longer
exists.