[Tutor] map vs. list comprehension
Andre Roberge
andre.roberge at gmail.com
Tue Feb 14 21:46:43 CET 2006
On 2/14/06, Michael Broe <mbroe at columbus.rr.com> wrote:
> I read somewhere that the function 'map' might one day be deprecated
> in favor of list comprehensions.
>
> But I can't see a way to do this in a list comprehension:
>
> >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4])
> [2, 4, 8, 16]
>>> [2**i for i in [1, 2, 3, 4]]
[2, 4, 8, 16]
André
>
> Is there a way?
>
> Cheers,
> Mike
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list