This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Chas Belov
Recipients Chas Belov, docs@python
Date 2020-05-16.06:57:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589612270.24.0.155728110455.issue40641@roundup.psfhosted.org>
In-reply-to
Content
In the tutorial for lambda expressions at https://docs.python.org/3.7/tutorial/controlflow.html#lambda-expressions the reserved word pair is introduced without noting that it is a reserved word. In the example given, I wasn't sure whether pair was a reserved word or whether the interpreter was parsing the plural "pairs" which is presumable an arbitrary name.

Actual content:

The above example uses a lambda expression to return a function. Another use is to pass a small function as an argument:

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

Candidate expected content:

The above example uses a lambda expression to return a function. Another use is to pass a small function as an argument, for example, the reserved word pair to designate the position in a tuple pair:

>>> items = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
>>> items.sort(key=lambda pair: pair[1])
>>> items
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]
History
Date User Action Args
2020-05-16 06:57:50Chas Belovsetrecipients: + Chas Belov, docs@python
2020-05-16 06:57:50Chas Belovsetmessageid: <1589612270.24.0.155728110455.issue40641@roundup.psfhosted.org>
2020-05-16 06:57:50Chas Belovlinkissue40641 messages
2020-05-16 06:57:50Chas Belovcreate