Kasper Guldmann writes:
> I was playing around with lambda functions, but I cannot seem to
> fully grasp them. I was running the script below in Python 2.7.5,
> and it doesn't do what I want it to. Are lambda functions really
> supposed to work that way. How do I make it work as I intend?
>
> f =
On Friday, September 20, 2013 8:51:20 PM UTC+5:30, Kasper Guldmann wrote:
> I was playing around with lambda functions, but I cannot seem to fully grasp
> them. I was running the script below in Python 2.7.5, and it doesn't do what
> I want it to. Are lambda functions really supposed to work that w
On 20/09/2013 16:21, Kasper Guldmann wrote:
I was playing around with lambda functions, but I cannot seem to fully grasp
them. I was running the script below in Python 2.7.5, and it doesn't do what
I want it to. Are lambda functions really supposed to work that way. How do
I make it work as I int
On Sat, Sep 21, 2013 at 1:21 AM, Kasper Guldmann wrote:
> f = []
> for n in range(5):
> f.append( lambda x: x*n )
You're leaving n as a free variable here. The lambda function will
happily look to an enclosing scope, so this doesn't work. But there is
a neat trick you can do:
f = []
for n in
I was playing around with lambda functions, but I cannot seem to fully grasp
them. I was running the script below in Python 2.7.5, and it doesn't do what
I want it to. Are lambda functions really supposed to work that way. How do
I make it work as I intend?
f = []
for n in range(5):
f.append(