About 3,450,000 results
Open links in new tab
  1. What exactly is "lambda" in Python? - Stack Overflow

    Mar 8, 2011 · Lambda is more of a concept or programming technique then anything else. Basically it's the idea that you get a function (a first-class object in python) returned as a result …

  2. What is `lambda` in Python code? How does it work with `key` …

    I saw some examples using built-in functions like sorted, sum etc. that use key=lambda. What does lambda mean here? How does it work? For the general computer science concept of a …

  3. Understanding lambda in Python and using it to pass multiple …

    Understanding lambda in Python and using it to pass multiple arguments Asked 13 years, 6 months ago Modified 2 years, 5 months ago Viewed 334k times

  4. Is there a way to perform "if" in python's lambda? [duplicate]

    In Python 2.6, I want to do: f = lambda x: if x==2 print x else raise Exception() f(2) #should print "2" f(3) #should throw an exception This clearly isn't the syntax. Is it possible to perform an if in …

  5. python - How are lambdas useful? - Stack Overflow

    Python's lambda keyword: unnecessary, occasionally useful. If you find yourself doing anything remotely complex with it, put it away and define a real function.

  6. python - loop for inside lambda - Stack Overflow

    May 11, 2022 · I need to simplify my code as much as possible: it needs to be one line of code. I need to put a for loop inside a lambda expression, something like that: x = lambda x: (for i in x …

  7. python - Why use lambda functions? - Stack Overflow

    From another angle: Lambda expressions are also known as "anonymous functions", and are very useful in certain programming paradigms, particularly functional programming, which lambda …

  8. python - Syntax behind sorted (key=lambda: ...) - Stack Overflow

    I don't quite understand the syntax behind the sorted() argument: key=lambda variable: variable[0] Isn't lambda arbitrary? Why is variable stated twice in what looks like a dict?

  9. python - Lambda inside lambda - Stack Overflow

    May 31, 2013 · p = lambda x: (lambda x: x%2)(x)/2 Note in Python 2 this example will always return 0 since the remainder from dividing by 2 will be either 0 or 1 and integer-dividing that …

  10. How to use await in a python lambda - Stack Overflow

    One can make a "thunk" with lambda which returns the call result of an async function--in other words, the coroutine. That coroutine can then be await ed as normal. Eg: await (lambda: …