Created
July 31, 2014 05:47
-
-
Save dagbrown/dcd907f6348548632eb4 to your computer and use it in GitHub Desktop.
Python WTF
This file contains hidden or 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
Python 2.7.7 (default, Jul 19 2014, 21:44:39) | |
[GCC 4.8.3] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> [ 1, 2, 3 ] + "hi there" | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: can only concatenate list (not "str") to list | |
>>> x = [ 1,2,3 ];x += "hi there"; x | |
[1, 2, 3, 'h', 'i', ' ', 't', 'h', 'e', 'r', 'e'] | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ya, the internal optimization of
+=
to__iadd__
can have other fun implications… this one caused a bug in some of my code: