1
0
mirror of https://github.com/satwikkansal/wtfpython synced 2024-11-21 18:54:20 +01:00

Merge pull request #221 from cl0ne/patch-1

Add link to Python FAQ to "Mutating the immutable"
This commit is contained in:
Satwik Kansal 2020-09-17 07:39:11 +05:30 committed by GitHub
commit 19e6b7da57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

1
README.md vendored
View File

@ -1701,6 +1701,7 @@ But I thought tuples were immutable...
An object of an immutable sequence type cannot change once it is created. (If the object contains references to other objects, these other objects may be mutable and may be modified; however, the collection of objects directly referenced by an immutable object cannot change.)
* `+=` operator changes the list in-place. The item assignment doesn't work, but when the exception occurs, the item has already been changed in place.
* There's also an explanation in [official Python FAQ](https://docs.python.org/3/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works).
---