a=[ lambda t: t**n for n in range(4) ]
Terry Hancock
hancock at anansispaceworks.com
Sat Apr 23 00:52:07 EDT 2005
On Friday 22 April 2005 06:44 pm, Scott David Daniels wrote:
> Terry Hancock wrote:
> > On Friday 22 April 2005 05:18 pm, mehmetmutigozel at gmail.com wrote:
> >
> > Perhaps you don't know how to call such functions? E.g.:
> > a=[ lambda t: t**n for n in range(4) ]
> >>>>a[2](3)
> > 27
>
> Didn't you notice this was a funny value?
Nope. Wasn't paying attention. ;-)
Just copied the code from the OP.
> Perhaps you mean:
> a = [lambda t, n=n: t**n for n in range(4)]
This is of course what he should've written, and/or what I
should've corrected it to, thank you.
Cheers,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Python-list
mailing list