[Python-checkins] cpython (3.5): Issue27203 - Fix doctests Doc/faq/programming.rst.

senthil.kumaran python-checkins at python.org
Sat Jun 4 23:08:12 EDT 2016


https://hg.python.org/cpython/rev/fea14da8442d
changeset: 101738:fea14da8442d
branch: 3.5
parent: 101736:97bdba07e361
user: Senthil Kumaran <senthil at uthcode.com>
date: Sat Jun 04 20:07:34 2016 -0700
summary:
 Issue27203 - Fix doctests Doc/faq/programming.rst.
Patch contributed by Jelle Zijlstra.
files:
 Doc/faq/programming.rst | 28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst
--- a/Doc/faq/programming.rst
+++ b/Doc/faq/programming.rst
@@ -1171,16 +1171,28 @@
 
 >>> A = [[None] * 2] * 3
 
-This looks correct if you print it::
+This looks correct if you print it:
+
+.. testsetup::
+
+ A = [[None] * 2] * 3
+
+.. doctest::
 
 >>> A
 [[None, None], [None, None], [None, None]]
 
 But when you assign a value, it shows up in multiple places:
 
- >>> A[0][0] = 5
- >>> A
- [[5, None], [5, None], [5, None]]
+.. testsetup::
+
+ A = [[None] * 2] * 3
+
+.. doctest::
+
+ >>> A[0][0] = 5
+ >>> A
+ [[5, None], [5, None], [5, None]]
 
 The reason is that replicating a list with ``*`` doesn't create copies, it only
 creates references to the existing objects. The ``*3`` creates a list
@@ -1664,9 +1676,9 @@
 next freshly created object is allocated at the same position in memory. This
 is illustrated by this example:
 
->>> id(1000)
+>>> id(1000) # doctest: +SKIP
 13901272
->>> id(2000)
+>>> id(2000) # doctest: +SKIP
 13901272
 
 The two ids belong to different integer objects that are created before, and
@@ -1675,9 +1687,9 @@
 to the object:
 
 >>> a = 1000; b = 2000
->>> id(a)
+>>> id(a) # doctest: +SKIP
 13901272
->>> id(b)
+>>> id(b) # doctest: +SKIP
 13891296
 
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /