◐ Shell
clean mode source ↗

Message 230389 - Python tracker

Here is what other mutable types do:

>>> s = []
>>> s.__iadd__(1)
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    s.__iadd__(1)
TypeError: 'int' object is not iterable

>>> s = set()
>>> s.__ior__(1)
NotImplemented

>>> from collections import deque
>>> s = deque()
>>> s.__iadd__(1)
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    s.__iadd__(1)
TypeError: 'int' object is not iterable

>>> from array import array
>>> s = array('i')
>>> s.__iadd__(1)
Traceback (most recent call last):
  File "<pyshell#10>", line 1, in <module>
    s.__iadd__(1)
TypeError: can only extend array with array (not "int")

>>> s = bytearray()
>>> s.__iadd__(1)
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    s.__iadd__(1)
TypeError: can't concat int to bytearray