Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a90e364

Browse files
committed
Issue #12666: Added section about map changes.
1 parent df9a5f5 commit a90e364

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/howto/pyporting.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,18 @@ Otherwise it might very well be worth your time and effort to port your tests
505505
to :mod:`unittest`.
506506

507507

508+
Update `map` for imbalanced input sequences
509+
'''''''''''''''''''''''''''''''''''''''''''
510+
511+
With Python 2, `map` would pad input sequences of unequal length with
512+
`None` values, returning a sequence as long as the longest input sequence.
513+
514+
With Python 3, if the input sequences to `map` are of unequal length, `map`
515+
will stop at the termination of the shortest of the sequences. For full
516+
compatibility with `map` from Python 2.x, also wrap the sequences in
517+
:func:`itertools.zip_longest`, e.g. ``map(func, *sequences)`` becomes
518+
``list(map(func, itertools.zip_longest(*sequences)))``.
519+
508520
Eliminate ``-3`` Warnings
509521
-------------------------
510522

0 commit comments

Comments
 (0)