8000 gh-133881: add forward reference to `list.sort()` in lambda expressio… · miss-islington/cpython@d95e663 · GitHub
[go: up one dir, main page]

Skip to content

Commit d95e663

Browse files
Shepard2154miss-islington
authored andcommitted
pythongh-133881: add forward reference to list.sort() in lambda expression tutorial (pythonGH-133910)
(cherry picked from commit c1c9ad1) Co-authored-by: Oleg Burnaev <51371645+Shepard2154@users.noreply.github.com>
1 parent bc0dc9d commit d95e663

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Doc/tutorial/controlflow.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@ scope::
998998
43
999999

10001000
The above example uses a lambda expression to return a function. Another use
1001-
is to pass a small function as an argument::
52BC
1001+
is to pass a small function as an argument. For instance, :meth:`list.sort`
1002+
takes a sorting key function *key* which can be a lambda function::
10021003

10031004
>>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
10041005
>>> pairs.sort(key=lambda pair: pair[1])

0 commit comments

Comments
 (0)
0