Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 25 Online
OpenStudy (anonymous):

Can someone explain anonymous functions?

OpenStudy (anonymous):

I don't intend this to sound snippy, but an anonymous function is a function that has no name. Here's a normal function to multiply its parameter by two: def MulByTwo(x): return x * 2 But Python, like some other languages, lets you define such a function for use without having to create a name for it, and avoid cluttering the namespace with names that you don't really need. In such a case, you create the same function with "lambda x: x * 2". So why would you want to do that? In so-called functional programming, you often want to pass a function as a parameter to another function. This lets you do that without creating a name that will never be used explicitly.

OpenStudy (anonymous):

thanks, so in passing a function as a parameter, i'm not passing the result, but simply a function/process to manipulate data/variables in another function?

OpenStudy (anonymous):

That's the general idea. I don't use it much; for a complete explanation, see http://docs.python.org/howto/functional.html.

OpenStudy (anonymous):

Thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
somnium: testing rq
1 hour ago 1 Reply 0 Medals
Lilmunchin: Trump or Biden
1 hour ago 69 Replies 3 Medals
ARTSMART: Art!
4 hours ago 5 Replies 5 Medals
Jasonisyours: What were the key causes of the French Revolution in 1789?
4 hours ago 3 Replies 5 Medals
PureSoulless: Why is the word "Pedophile" always censored in yt vids?
1 day ago 3 Replies 0 Medals
Jalli: What's 58x3634u00b07
1 day ago 6 Replies 3 Medals
arriya: who wanna play roblox
1 day ago 5 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!