Python lambda functions
Python allows to define anonymous functions (i.e. function not bounded to a name). You can easily identify this functions’ type because are defined using the keyword lambda.
The following example contains two functions f and g both returning the sum of the two arguments x and y. The function f is defined using the lambda operator and the g function is defined in the traditional way.
The lambda functions could be sometimes difficult to understand and their use could reduce the code readability. They can be useful if used in conjunction with filter,lambda and reduce built-in function, indeed these three functions require as first argument a function. You can add a comment before the lambda function in order to increase readability as in the following examples: