About 199,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. Is there a way to perform "if" in python's lambda?

    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:

  3. python - List comprehension vs. lambda + filter - Stack Overflow

    I find the list comprehension much clearer than filter + lambda, but use whichever you find easier. There are two things that may slow down your use of filter. The first is the function call …

  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. Understanding lambda in Python and using it to pass multiple …

    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 …

  6. python - Define a lambda expression that raises an Exception

    Nov 28, 2011 · The result of this map operation is a list with one entry, the one returned by lambda x, y, z, which is why we need this lambda: if we would use __setattr__ right away, we …

  7. python max function using 'key' and lambda expression

    Aug 18, 2013 · I come from OOP background and trying to learn python. I am using the max function which uses a lambda expression to return the instance of type Player having …

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

    SyntaxError: 'await' outside async function async lambda x: ... throws SyntaxError: invalid syntax. Pep 492 states: Syntax for asynchronous lambda functions could be provided, but this …

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

    In Python, lambda is a keyword used to define anonymous functions (i.e., functions that don't have a name), sometimes called lambda functions (after the keyword, which in turn comes …

  10. E731 do not assign a lambda expression, use a def - Stack Overflow

    Jan 24, 2022 · I get this pep8 warning whenever I use lambda expressions. Are lambda expressions not recommended? If not why?