Skip to content

Commit cc79837

Browse files
committed
Issue #21545: Add .pop example and tweak comment about pure mutation methods.
Patch prepared by David Harrigan.
1 parent fd61349 commit cc79837

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Doc/tutorial/datastructures.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ An example that uses most of the list methods::
9999
>>> a.sort()
100100
>>> a
101101
[-1, 1, 66.25, 333, 333, 1234.5]
102+
>>> a.pop()
103+
1234.5
104+
>>> a
105+
[-1, 1, 66.25, 333, 333]
106+
107+
You might have noticed that methods like ``insert``, ``remove`` or ``sort`` that
108+
only modify the list have no return value printed -- they return the default
109+
``None``. [1]_ This is a design principle for all mutable data structures in
110+
Python.
102111

103112

104113
.. _tut-lists-as-stacks:

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ Barry Hantman
506506
Lynda Hardman
507507
Derek Harland
508508
Jason Harper
509+
David Harrigan
509510
Brian Harring
510511
Jonathan Hartley
511512
Travis B. Hartwell

0 commit comments

Comments
 (0)