From b84510f4e5c84fd6d704814826148c639c99251c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E7=BB=98=E6=9D=A8?= Date: Sat, 5 May 2018 18:08:52 +0800 Subject: [PATCH 1/4] Change description about doc in programming, faq. The description `and in all cases in the standard library` is not good. --- Doc/faq/programming.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index 1a2f582a31ad17..d2fd59f30bb459 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -472,12 +472,13 @@ object ``x`` refers to). After this assignment we have two objects (the ints Some operations (for example ``y.append(10)`` and ``y.sort()``) mutate the object, whereas superficially similar operations (for example ``y = y + [10]`` -and ``sorted(y)``) create a new object. In general in Python (and in all cases +and ``sorted(y)``) create a new object. In general in Python (and almost cases in the standard library) a method that mutates an object will return ``None`` -to help avoid getting the two types of operations confused. So if you -mistakenly write ``y.sort()`` thinking it will give you a sorted copy of ``y``, -you'll instead end up with ``None``, which will likely cause your program to -generate an easily diagnosed error. +to help avoid getting the two types of operations confused.( A specific case +is that ``a_list.pop([index])`` will remove and return item at index +(default last). ) So if you mistakenly write ``y.sort()`` thinking it will +give you a sorted copy of ``y``, you'll instead end up with ``None``, which will +likely cause your program to generate an easily diagnosed error. However, there is one class of operations where the same operation sometimes has different behaviors with different types: the augmented assignment From bfcaa1affc8f5f88ca7543b29eb7104ed17b4995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E7=BB=98=E6=9D=A8?= Date: Sat, 5 May 2018 18:30:34 +0800 Subject: [PATCH 2/4] Change description about programming. Change description about programming. --- .../Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst diff --git a/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst b/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst new file mode 100644 index 00000000000000..18a3f42f422a97 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst @@ -0,0 +1 @@ +Change description about programming, faq for https://docs.python.org/3/ From ba74501d14195d8a48b304bf272fa95ff0fb90d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E7=BB=98=E6=9D=A8?= Date: Sat, 5 May 2018 18:32:58 +0800 Subject: [PATCH 3/4] Rename file Change description about programming, faq --- ...34331.E33Dg2.rst => 2018-05-05-18-28-29.bpo-334331.E33Dg2.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/Documentation/{2018-05-05-18-28-239.bpo-334331.E33Dg2.rst => 2018-05-05-18-28-29.bpo-334331.E33Dg2.rst} (100%) diff --git a/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst b/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-29.bpo-334331.E33Dg2.rst similarity index 100% rename from Misc/NEWS.d/next/Documentation/2018-05-05-18-28-239.bpo-334331.E33Dg2.rst rename to Misc/NEWS.d/next/Documentation/2018-05-05-18-28-29.bpo-334331.E33Dg2.rst From 741e5ecc479f0bad2a2d954c4e6ff61a3c4370f5 Mon Sep 17 00:00:00 2001 From: lvhuiyang Date: Sun, 6 May 2018 19:10:42 +0800 Subject: [PATCH 4/4] bpo-33431: Simplifying the paragraph --- Doc/faq/programming.rst | 12 +++++------- .../2018-05-05-18-28-29.bpo-334331.E33Dg2.rst | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index d2fd59f30bb459..5ddba40e19f793 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -472,13 +472,11 @@ object ``x`` refers to). After this assignment we have two objects (the ints Some operations (for example ``y.append(10)`` and ``y.sort()``) mutate the object, whereas superficially similar operations (for example ``y = y + [10]`` -and ``sorted(y)``) create a new object. In general in Python (and almost cases -in the standard library) a method that mutates an object will return ``None`` -to help avoid getting the two types of operations confused.( A specific case -is that ``a_list.pop([index])`` will remove and return item at index -(default last). ) So if you mistakenly write ``y.sort()`` thinking it will -give you a sorted copy of ``y``, you'll instead end up with ``None``, which will -likely cause your program to generate an easily diagnosed error. +and ``sorted(y)``) create a new object. In general in Python a method that +mutates an object will return ``None`` to help avoid getting the two types +of operations confused. So if you mistakenly write ``y.sort()`` thinking it +will give you a sorted copy of ``y``, you'll instead end up with ``None``, +which will likely cause your program to generate an easily diagnosed error. However, there is one class of operations where the same operation sometimes has different behaviors with different types: the augmented assignment diff --git a/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-29.bpo-334331.E33Dg2.rst b/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-29.bpo-334331.E33Dg2.rst index 18a3f42f422a97..21f4dbfbf450b4 100644 --- a/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-29.bpo-334331.E33Dg2.rst +++ b/Misc/NEWS.d/next/Documentation/2018-05-05-18-28-29.bpo-334331.E33Dg2.rst @@ -1 +1 @@ -Change description about programming, faq for https://docs.python.org/3/ +Removed wrong statement in programming faq.