On Tuesday 14 February 2006 20:57, Michael Broe wrote:
...
> 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]
>>> [ x**y for x,y in zip([2,2,2,2],[1,2,3,4]) ]
[2, 4, 8, 16]
To me this is clearer. (despite having written som
> 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]
Hi Michael,
If my hands were forcibly tied to avoid map(), I'd
On Feb 14, 2006, at 3:46 PM, Andre Roberge wrote:
> [2**i for i in [1, 2, 3, 4]]
Ah yes, I'm sorry, I was thinking of the most general case, where the
arguments are
two arbitrary lists. My example was too specific.
Is there a way to do something like the following in a list
comprehension?
Michael Broe 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]
>
> Is there a way?
The current plan is to
How about:
>>> [pow(2,x) for x in [1,2,3,4]]
[2, 4, 8, 16]
On 2/14/06, Michael Broe <[EMAIL PROTECTED]> wrote:
I read somewhere that the function 'map' might one day be deprecatedin favor of list comprehensions.But I can't see a way to do this in a list comprehension: >>> map (pow, [2, 2, 2, 2],
On 2/14/06, Michael Broe <[EMAIL PROTECTED]> 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
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]
Is there a way?
Cheers,
Mike
___