11 ms·
That's a wart and a half. It puzzles me to no end that this would be an error - `another_tuple[0].append(3)` is not an error.
by kzrdude 6y ago
That's a wart and a half. It puzzles me to no end that this would be an error - `another_tuple[0].append(3)` is not an error.
- pansa2 6y agoIt’s because `another_tuple[2] += [99, 999]` is equivalent to something similar to `another_tuple[2] = another_tuple[2].__iadd__([99, 999])`. The list is modified in __iadd__ but then the assignment fails. The assignment is necessary in case __iadd__ doesn’t want to modify in-place and instead return a new value. It’s this “sometimes modify in-place, sometimes don’t” which causes the issue.