Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +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 in all 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.
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed wrong statement in programming faq.