[Tutor] map() and lambda to change class instance attribute
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Thu May 12 07:50:02 CEST 2005
> 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]]
Right, what Terry said. Dear goodness, I'm getting really sloppy these
days; I must test my examples. Thanks for catching that for me.
More information about the Tutor
mailing list