Sunday, August 16, 2015

What is lambda in python?

Lamda, which is often used as inline function is a single expression anonymous function. We generally use it like this:

A lambda form in python does not have statements as it is used to make new function object and then return them at runtime.

lambda arg1 arg2 ... : <expression using args>

For eg.

>>> triangle_perimeter = lambda a,b,c:a+b+c
>>> triangle_perimeter(3,3,3)

9
5 Python: What is lambda in python? Lamda, which is often used as inline function is a single expression anonymous function. We generally use it like this: A lambda form in ...

No comments :

Post a Comment