@@ -583,17 +583,16 @@ In the same fashion, dictionaries can deliver keyword arguments with the ``**``\
583583
584584.. _tut-lambda :
585585
586- Lambda Forms
587- ------------
588-
589- By popular demand, a few features commonly found in functional programming
590- languages like Lisp have been added to Python. With the :keyword: `lambda `
591- keyword, small anonymous functions can be created. Here's a function that
592- returns the sum of its two arguments: ``lambda a, b: a+b ``. Lambda forms can be
593- used wherever function objects are required. They are syntactically restricted
594- to a single expression. Semantically, they are just syntactic sugar for a
595- normal function definition. Like nested function definitions, lambda forms can
596- reference variables from the containing scope::
586+ Lambda Expressions
587+ ------------------
588+
589+ Small anonymous functions can be created with the :keyword: `lambda ` keyword.
590+ This function returns the sum of its two arguments: ``lambda a, b: a+b ``.
591+ Lambda forms can be used wherever function objects are required. They are
592+ syntactically restricted to a single expression. Semantically, they are just
593+ syntactic sugar for a normal function definition. Like nested function
594+ definitions, lambda functions can reference variables from the containing
595+ scope::
597596
598597 >>> def make_incrementor(n):
599598 ... return lambda x: x + n
@@ -604,6 +603,14 @@ reference variables from the containing scope::
604603 >>> f(1)
605604 43
606605
606+ The above example uses a lambda expression to return a function. Another use
607+ is to pass a small function as an argument::
608+
609+ >>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
610+ >>> pairs.sort(key=lambda pair: pair[1])
611+ >>> pairs
612+ [(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
613+
607614
608615.. _tut-docstrings :
609616
0 commit comments