|
|
|
|
|
by btilly
5102 days ago
|
|
At that point it is not a named function. The name was only associated with the function in a scope that is now exited. Call the outer function 3 times. You'll wind up with 3 functions. They will be independent, even though you think they are all named the same thing. There is literally nothing you could want to do with anonymous functions that you cannot do with this technique. (Of course if you want to update an enclosed variable, you have to store it in a mutable data structure. But that is true for any Python function that wants to mutate data in its surrounding environment.) |
|
http://en.wikipedia.org/wiki/Anonymous_function
http://en.wikipedia.org/wiki/Closure_(computer_science)