About 50 results
Open links in new tab
  1. What exactly is "lambda" in Python? - Stack Overflow

    Mar 8, 2011 · 16 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 of another …

  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 lambda, see …

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

    After reading everything I can find on lambda expressions in Python, I still don't understand how to make it do what I want. Everyone uses the example: lambda x, y : x + y Why do you need to stat...

  4. 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.

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

    I don't know python (although it's definitely high on my to-learn list), so I'm wondering... is there really a good reason multiple lines aren't allowed for a lambda-expression? Why can't the body of the lambda …

  6. What does "lambda" mean in Python, and what's the simplest way to …

    Oct 18, 2009 · In Python it is only possible to make a lambda that returns a single expression, and the lambda cannot span multiple lines (unless you join the multiple lines by using the backslash-at-the …

  7. python - Lambda function in list comprehensions - Stack Overflow

    Mar 19, 2019 · Why is the output of the following two list comprehensions different, even though f and the lambda function are the same? f = lambda x: x*x [f(x) for x in range(10)] and [lambda x: x*x for x …

  8. python - Scope of lambda functions and their parameters ... - Stack ...

    Jun 2, 2009 · Python does uses references of course, but it does not matter in this context. When you define a lambda (or a function, since this is the exact same behavior), it does not evaluate the …

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

    An easy way to perform an if in lambda is by using list comprehension. You can't raise an exception in lambda, but this is a way in Python 3.x to do something close to your example:

  10. 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 result by 2 will …