Oct-10-2019, 04:35 AM
(This post was last modified: Oct-10-2019, 04:35 AM by knackwurstbagel.)
You are returning a function, a lambda is an anonymous function. Functions in Python are objects and can be passed around, mydoubler is now a function and can be called. What is hapening is that each time you call myfunc with a different integer you can get back a unique function that returns that value * its argument. You could say this is like a factory for creating functions on the fly that you don't have to type out manually. This is the best explanation I can think of that would hopefully help. I would lookup How to use Python Lambda Functions There are a lot of resources that can explain both lambdas and functions that return functions. That's where I would start looking.