Python Lambda Functions For Idiots

Python Lambda Functions For Idiots

What are Python Lambda Functions? They weren’t something I could easily infer from casually seeing it in code or context clues. I had to do a little digging. What I took from my reading, is that they are more concisely written functions.

My Setup

  • Python 3.x
  • macOS

Example

They make this:

def doSomething(foo):
    return foo

Into this:

doSomething = lambda foo:foo

I personally think they’re beautiful which is why I did the bit of research. I’ll have more tell as I incorporate Python Lambda functions into daily use. Happy coding!

Interested in further honing your Python lambda chops? Check out this article on using them to cast values.

Leave a Comment