-
-
Save 9seconds/7915921 to your computer and use it in GitHub Desktop.
Python WTFs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = (1, [2, 3]) | |
>>> a[1] += [4, 5] | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: 'tuple' object does not support item assignment | |
>>> print a | |
(1, [2, 3, 4, 5]) | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = [] | |
>>> b = a += [1] | |
File "<stdin>", line 1 | |
b = a += [1] | |
^ | |
SyntaxError: invalid syntax | |
>>> b = a.__iadd__([1]) | |
>>> print b | |
[1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment