[Tutor] map() and lambda to change class instance attribute
Terry Carroll
carroll at tjc.com
Thu May 12 00:30:59 CEST 2005
It's not often I get a chance to correct Danny, but....
On Wed, 11 May 2005, Danny Yoo wrote:
> map(lambda x: x^2, [1, 2, 3])
>
> [x^2 for x in [1, 2, 3]]
> then we're really saying something like this:
>
> [1, 2, 3]
> | | |
> | | | map()
> | | |
> V V V
> [1, 4, 9]
You probably don't want to invoke a bitwise exclusive-or here!
I think Danny meant:
map(lambda x: x**2, [1, 2, 3])
[x**2 for x in [1, 2, 3]]
More information about the Tutor
mailing list