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.

classification
Title: Tutorial: examples and comment about mutation methods
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: David.Harrigan, cvrebert, docs@python, ncoghlan, python-dev, rhettinger, terry.reedy
Priority: normal Keywords: patch

Created on 2014-05-20 21:37 by terry.reedy, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
datastructures.patch David.Harrigan, 2014-05-22 14:36 review
Messages (6)
msg218857 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-05-20 21:37
The Tutorial section More on Lists
https://docs.python.org/3.4/tutorial/datastructures.html#more-on-lists includes list.pop but ignores it in the example and final comment. I think the examples should be augmented and the comment modified.

1. (simplest) End the example block with

>>> a.pop()
1234.5
>>> a
[-1, 1, 66.25, 333, 333]

2. The comment says "You might have noticed that methods like insert, remove or sort that modify the list have no return value printed – they return None. [1] This is a design principle for all mutable data structures in Python." [The footnote says "[1] Other languages may return the mutated object, which allows method chaining, such as d->insert("a")->remove("b")->sort();."]

Inserting 'only' before 'modify' makes the statement true even now with .pop added. I think 'the default' should be added before 'None', but that would be optional. I do not think .pop needs to be explicitly mentioned here since the point of the comment is to explain the lack of a printed return value, and .pop does have a printed return value.
msg218897 - (view) Author: David Harrigan (David.Harrigan) * Date: 2014-05-22 14:36
I've added the example and modified the final comment.
msg218927 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2014-05-22 22:42
That looks good and is ready to apply.
msg218946 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-23 04:35
New changeset 6fc09f30b514 by Terry Jan Reedy in branch '2.7':
Issue #21545: Add .pop example and tweak comment about pure mutation methods.
http://hg.python.org/cpython/rev/6fc09f30b514

New changeset 3f2b6034b73a by Terry Jan Reedy in branch '3.4':
Issue #21545: Add .pop example and tweak comment about pure mutation methods.
http://hg.python.org/cpython/rev/3f2b6034b73a
msg218947 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-05-23 04:38
Thanks David. If this is not to be your last contribution, and we hope not, please fill out the contributor agreement, if you have hot already, at
https://www.python.org/psf/contrib/contrib-form/
msg218967 - (view) Author: David Harrigan (David.Harrigan) * Date: 2014-05-23 12:37
Thanks for the info, I've signed the agreement.
History
Date User Action Args
2022-04-11 14:58:03adminsetgithub: 65744
2014-05-23 12:37:02David.Harrigansetmessages: + msg218967
2014-05-23 04:38:02terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg218947

stage: needs patch -> resolved
2014-05-23 04:35:16python-devsetnosy: + python-dev
messages: + msg218946
2014-05-22 22:42:01rhettingersetnosy: + rhettinger
messages: + msg218927
2014-05-22 14:36:01David.Harrigansetfiles: + datastructures.patch

nosy: + David.Harrigan
messages: + msg218897

keywords: + patch
2014-05-20 22:56:53cvrebertsetnosy: + cvrebert
2014-05-20 21:37:33terry.reedycreate