Issue 7203: fixer for map(None, ...) needs to consider multi-argument case (original) (raw)

Created on 2009-10-25 17:53 by georg.brandl, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (8)
msg94455 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-10-25 17:53
Currently, ``map(None, a)`` is recognized and converted to ``list(a)`` which is correct but quite useless. ``map(None, a, b, ...)`` is not treated specially. An approximate translation would be ``map(lambda *xs: xs, a, b, ...)`` which however doesn't take into account that the new map cuts after the shortest sequence instead of "filling up" the shorter ones with Nones. That should probably produce a warning.
msg94456 - (view) Author: Florian Mayer (segfaulthunter) Date: 2009-10-25 18:23
A full fix would be list(map(fun, *zip(*itertools.zip_longest(a, b, ...)))) and if fun is None list(map(lambda *xs: xs, *zip(*itertools.zip_longest(a, b, ...))))
msg94513 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-26 21:30
Fixed in r75734.
msg94576 - (view) Author: Florian Mayer (segfaulthunter) Date: 2009-10-27 19:52
I dare to disagree on this being an adequate fix. Request to reopen.
msg94577 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-27 20:22
2009/10/27 Florian Mayer <report@bugs.python.org>: > > Florian Mayer <flormayer@aim.com> added the comment: > > I dare to disagree on this being an adequate fix. Request to reopen. What would you prefer?
msg94579 - (view) Author: Florian Mayer (segfaulthunter) Date: 2009-10-27 20:43
At least converting map(None, a, b, ...) to map(lambda *xs: xs, a, b, ...) I can understand if you prefer not to add the itertools.zip_longest workaround, although that would be the correct translation, of course.
msg94580 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-10-27 20:57
2009/10/27 Florian Mayer <report@bugs.python.org>: > > Florian Mayer <flormayer@aim.com> added the comment: > > At least converting > > map(None, a, b, ...) > > to > > map(lambda *xs: xs, a, b, ...) Well, since that's not always correct, we should not translate to it.
msg94581 - (view) Author: Florian Mayer (segfaulthunter) Date: 2009-10-27 20:58
When could this possibly be wrong, if I may ask?
History
Date User Action Args
2022-04-11 14:56:54 admin set github: 51452
2009-10-27 20:58:37 segfaulthunter set messages: +
2009-10-27 20:57:51 benjamin.peterson set messages: +
2009-10-27 20:43:35 segfaulthunter set messages: +
2009-10-27 20:22:46 benjamin.peterson set messages: +
2009-10-27 19:52:53 segfaulthunter set messages: +
2009-10-26 21:30:10 benjamin.peterson set status: open -> closednosy: + benjamin.petersonmessages: + resolution: fixed
2009-10-25 18:23:09 segfaulthunter set messages: +
2009-10-25 18:19:01 segfaulthunter set nosy: + segfaulthunter
2009-10-25 17:53:24 georg.brandl create