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.
Created on 2012年09月28日 03:50 by chris.jerdonek, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue16073.patch | inglesp, 2012年09月28日 13:28 | review | ||
| Messages (5) | |||
|---|---|---|---|
| msg171405 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月28日 03:50 | |
> Date: 2012年9月20日 15:14:36 -0400 > To: docs@python.org > Subject: [docs] map objects are not lists > > 5.1.3. List Comprehensions<http://docs.python.org/dev/tutorial/datastructures.html#list-comprehensions> > > List comprehensions provide a concise way to create lists. Common > applications are to make new lists where each element is the result of some > operations applied to each member of another sequence or iterable, or to > create a subsequence of those elements that satisfy a certain condition. > > For example, assume we want to create a list of squares, like: >>>> > >>>> squares = []>>> for x in range(10):... squares.append(x**2)...>>> squares[0, 1, 4, 9, 16, 25, 36, 49, 64, 81] > > We can obtain the same result with: > > squares = [x**2 for x in range(10)] > > This is also equivalent to squares = map(lambda x: x**2, range(10)), but > it?s more concise and readable. > > > I think that the last sentence above should read: > > squares = list(map(lambda x: x**2, range(10))) > > In other words, the map function returns a map object, not a list object, > so the list() function needs to be used to convert it to something that is > truly equivalent to the previous definitions of "squares". (In case it > matters, I am using Python-3.3.0rc2 on RHEL 6.3.) (from http://mail.python.org/pipermail/docs/2012-September/010525.html ) |
|||
| msg171459 - (view) | Author: Peter Inglesby (inglesp) * | Date: 2012年09月28日 13:28 | |
Have attached a patch with suggested update. Have also grepped for similar issues elsewhere in documentation, and haven't found anything, but may have missed something. |
|||
| msg171468 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月28日 13:58 | |
2.7 is not affected. |
|||
| msg171474 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年09月28日 14:26 | |
New changeset 6c96878eb729 by Chris Jerdonek in branch '3.2': Close issue #16073: fix map() example in list comprehension documentation. http://hg.python.org/cpython/rev/6c96878eb729 New changeset 8a4a88b1e964 by Chris Jerdonek in branch 'default': Close issue #16073: merge fix from 3.2. http://hg.python.org/cpython/rev/8a4a88b1e964 |
|||
| msg171476 - (view) | Author: Chris Jerdonek (chris.jerdonek) * (Python committer) | Date: 2012年09月28日 14:30 | |
Thanks for helping with the patch and search, Peter. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:36 | admin | set | github: 60277 |
| 2012年09月28日 14:30:14 | chris.jerdonek | set | status: open -> closed resolution: fixed messages: + msg171476 stage: needs patch -> resolved |
| 2012年09月28日 14:26:09 | python-dev | set | nosy:
+ python-dev messages: + msg171474 |
| 2012年09月28日 13:58:46 | chris.jerdonek | set | assignee: docs@python -> chris.jerdonek messages: + msg171468 versions: + Python 3.2 |
| 2012年09月28日 13:28:52 | inglesp | set | files:
+ issue16073.patch nosy: + inglesp messages: + msg171459 keywords: + patch |
| 2012年09月28日 03:50:23 | chris.jerdonek | create | |