[Python-ideas] why has itertools.imap other semantics as the bultin map?
George Sakkis
george.sakkis at gmail.com
Wed Apr 28 18:44:49 CEST 2010
On Wed, Apr 28, 2010 at 5:59 PM, Mathias Panzenböck
<grosser.meister.morti at gmx.net> wrote:
> See:
>>>> map(None,['a','b'],[])
> [('a', None), ('b', None)]
>>>> list(imap(None,['a','b'],[]))
> []
>
> Why is that? I propose that imap should work like map (except from being a
> generator, of course).
>
> System Info:
> Python 2.6.2 (r262:71600, Jan 25 2010, 18:46:47)
> [GCC 4.4.2 20091222 (Red Hat 4.4.2-20)] on linux2
Practically speaking, Python 2.7 is in beta so even if there was no
objection, it's pretty unlikely this lands in 2.x (and 3.x has dropped
itertools.imap so there's no confusion).
By the way, that's not the only difference of map and itertools.imap:
>>> map(None, 'abc')
['a', 'b', 'c']
>>> list(itertools.imap(None, 'abc'))
[('a',), ('b',), ('c',)]
George
More information about the Python-ideas
mailing list