Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e17de09

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

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Doc/tutorial/datastructures.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,15 @@ An example that uses most of the list methods::
111111
>>> a.sort()
112112
>>> a
113113
[-1, 1, 66.25, 333, 333, 1234.5]
114+
>>> a.pop()
115+
1234.5
116+
>>> a
117+
[-1, 1, 66.25, 333, 333]
114118

115119
You might have noticed that methods like ``insert``, ``remove`` or ``sort`` that
116-
modify the list have no return value printed -- they return ``None``. [1]_ This
117-
is a design principle for all mutable data structures in Python.
120+
only modify the list have no return value printed -- they return the default
121+
``None``. [1]_ This is a design principle for all mutable data structures in
122+
Python.
118123

119124

120125
.. _tut-lists-as-stacks:

Misc/ACKS

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

0 commit comments

Comments
 (0)