0

i've been looking at the lambda function lately.

I see that its similar to an anonymous function which is generally used to pass into a higher order function.

Is there any difference in this function compared to the normal function?

2
  • A lambda expression is used to create anonymous functions. There is nothing about the resulting function object that is different or special compared to a function created using a full, function definition statement. The only way you could probably tell it was created using a lambda expression is that the .__name__ attribute will be '<lambda>'. It is a convenience Commented Mar 30, 2021 at 17:10
  • lambda function has some restricions. For example it can't use = to assing value to variable. It can't use if without else - only special version value1 if state else value2. Probably It can't use return to exit in different moments. For more complex code normal function can be more useful and more readable - and simpler do debug. Commented Mar 30, 2021 at 17:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.