list*list
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Wed May 3 17:13:54 EDT 2006
Ziga Seilnach:
>c = map(operator.mul, a, b)
Usually I like map a lot, but this time for me the l.c. version is a
bit simpler to understand (even if it's longer, and maybe slower too):
>>> from operator import mul
>>> from itertools import izip
>>> a = [1, 2, 3]
>>> b = [4, 5, 6]
>>> map(mul, a, b)
[4, 10, 18]
>>> [arow * brow for arow, brow in izip(a, b)]
[4, 10, 18]
Bye,
bearophile
More information about the Python-list
mailing list