2 ms·
Wait...did it throw an exception, yet still add the item to the list? EDIT: Tried it myself. Sure enough, it throws the exception, but still adds the item. T
by Sohcahtoa82 7y ago
Wait...did it throw an exception, yet still add the item to the list?
EDIT: Tried it myself. Sure enough, it throws the exception, but still adds the item. This seems like a bug.
EDIT Part 2: I understand now. `a[0] += [1]` is internally translated to `a[0] = a[0].__iadd__([1])`. The right-hand side is interpreted, mutating a[0] in-place as expected. But then the re-assignment happens, which throws the exception since you're trying to re-assign a value in a tuple, which is immutable.
- masklinn 7y agoYou got it, that’s why it’s so odd.