Skip to main content

Lambda functions

I often forget the syntax and usage of lambda functions, the following examples should help as a reminder.

>>> def function(x):

... return x*3

...

>>> function(2)

6

>>> func_with_lambda = lambda x: x*2

>>> func_with_lambda(2)

4

>>> (lambda x: x*2)(2)

4

>>>