itertools.izip brokeness
bonono at gmail.com
bonono at gmail.com
Tue Jan 3 07:25:28 EST 2006
Paul Rubin wrote:
> bonono at gmail.com writes:
> > map(None,[1,2,3],[4,5]) gives [(1,4),(2,5),(3,None)]
>
> I didn't know that until checking the docs just now. Oh man, what a
> hack! I always thought Python should have a built-in identity
> function for situations like that. I guess it does the above instead.
> Thanks. Jeez ;-)
Of course, for OP's particular case, I think a specialized func() is
even better, as the None are turned into "" in the process which is
needed for string operation.
map(lambda *arg: tuple(map(lambda x: x is not None and x or "", arg)),
["a","b","c"],["d","e"])
More information about the Python-list
mailing list