Last active
August 29, 2015 14:08
-
-
Save wrobstory/31734bc2ef4b5f4c4048 to your computer and use it in GitHub Desktop.
Polymorphism?
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
In [1]: 1 + 1 | |
Out[1]: 2 | |
In [2]: 1 + 1.0 | |
Out[2]: 2.0 | |
In [3]: 1 + "string" | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-3-d295ea69933a> in <module>() | |
----> 1 1 + "string" | |
TypeError: unsupported operand type(s) for +: 'int' and 'str' | |
In [4]: 1 + True | |
Out[4]: 2 | |
In [5]: 1 + None | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-5-3545813ae2b1> in <module>() | |
----> 1 1 + None | |
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' | |
In [6]: True + False | |
Out[6]: 1 | |
In [7]: True + None | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-7-6f28c7b268c5> in <module>() | |
----> 1 True + None | |
TypeError: unsupported operand type(s) for +: 'bool' and 'NoneType' | |
In [8]: True + "string" | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-8-2e981efb30c0> in <module>() | |
----> 1 True + "string" | |
TypeError: unsupported operand type(s) for +: 'bool' and 'str' | |
In [9]: "string" + "string" | |
Out[9]: 'stringstring' | |
In [10]: "string" + None | |
--------------------------------------------------------------------------- | |
TypeError Traceback (most recent call last) | |
<ipython-input-10-31b8af0d9e55> in <module>() | |
----> 1 "string" + None | |
TypeError: cannot concatenate 'str' and 'NoneType' objects | |
In [11]: 1.0 + True | |
Out[11]: 2.0 |
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
In [1]: True = None | |
In [2]: False = None | |
In [3]: True is False | |
Out[3]: True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment