Created
January 18, 2019 06:21
-
-
Save mahmoud/f19641c7d44922e1defb9b284951f3e7 to your computer and use it in GitHub Desktop.
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
>>> x = [1] | |
>>> y = (2, 3) | |
>>> x + y | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: can only concatenate list (not "tuple") to list | |
>>> x += y | |
>>> x | |
[1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is defensible in the sense that += is asymmetric (left side is special and gets to determine type)
whereas + is meant to be symmetric -- A + B vs B + A should almost always evaluate to the same value