classification
Title: Mislabeling of a dict comprehension as a generator expression in the tutorial
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Soothsayer, docs@python, matrixise, xiang.zhang
Priority: normal Keywords: patch

Created on 2018-01-30 05:41 by Soothsayer, last changed 2018-02-01 07:32 by xiang.zhang. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5446 merged matrixise, 2018-01-30 10:29
Messages (6)
msg311235 - (view) Author: (Soothsayer) Date: 2018-01-30 05:41
In the Python tutorial, in "9. Classes", in "9.10 Generator expression", a list of sample generator expressions used as arguments to functions is given. However, one of the examples isn't a generator expression, it's a set comprehension.

sine_table = {x: sin(x*pi/180) for x in range(0, 91)}

Perhaps this used to be a call to set() and was mistakenly converted?
msg311236 - (view) Author: (Soothsayer) Date: 2018-01-30 05:44
Correction: it's a dictionary comprehension, and it did indeed used to be a call to dict() in the 2.7 documentation.
msg311265 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2018-01-30 10:37
This example is also in 2.7 
https://docs.python.org/2.7/tutorial/classes.html#generator-expressions

-> I add 2.7
msg311304 - (view) Author: (Soothsayer) Date: 2018-01-30 23:18
I agree that 2.7 is incorrect also, 2.7 has dict comprehensions also so there's no reason to pass a generator expression to dict().

I add 3.4 and 3.8 because they also have the problem.
msg311404 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-02-01 07:31
New changeset ab328756d7fd969ee4882458b07892dff135013c by Xiang Zhang (Stéphane Wirtel) in branch 'master':
bpo-32722: Remove useless example in the Classes tutorial (#5446)
https://github.com/python/cpython/commit/ab328756d7fd969ee4882458b07892dff135013c
msg311405 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-02-01 07:32
I treat it as an enhancement so only merge it into 3.8. Thanks Soothsayer for the report and Stéphane for the patch!
History
Date User Action Args
2018-02-01 07:32:10xiang.zhangsetstatus: open -> closed
versions: - Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7
messages: + msg311405

resolution: fixed
stage: patch review -> resolved
2018-02-01 07:31:10xiang.zhangsetnosy: + xiang.zhang
messages: + msg311404
2018-01-30 23:18:14Soothsayersetmessages: + msg311304
versions: + Python 3.4, Python 3.8
2018-01-30 20:28:48brett.cannonsettitle: Classes -> Mislabeling of a dict comprehension as a generator expression in the tutorial
2018-01-30 10:37:22matrixisesetnosy: + matrixise

messages: + msg311265
versions: + Python 2.7
2018-01-30 10:29:51matrixisesetkeywords: + patch
stage: patch review
pull_requests: + pull_request5278
2018-01-30 05:44:19Soothsayersetmessages: + msg311236
versions: + Python 3.7
2018-01-30 05:41:46Soothsayersetversions: + Python 3.5, Python 3.6, - Python 3.7, Python 3.8
2018-01-30 05:41:01Soothsayercreate