I answered this question and ran into the following problem:
>>> from operator import add >>> map(add,[1,2,3],[1,2]) Traceback (most recent call last): File "<pyshell#47>", line 1, in <module> map(add,[1,2,3],[1,2]) TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
I wanted map stop as soon as the smallest iterator contained in the parameters was consumed.
I found a solution:
>>> from itertools import imap >>> list(imap(add,[1,2,3],[1,2])) [2, 4]
But why? Should their behavior be consistent?
Is this the best way to solve the problem?
ovgolovin
source share