Created
May 23, 2011 20:31
-
-
Save asmeurer/987535 to your computer and use it in GitHub Desktop.
str(list) calls __repr__ instead of __str__
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
>>> class MyClass(object): | |
... def __repr__(self): | |
... return "repr" | |
... def __str__(self): | |
... return "str" | |
... | |
>>> repr(MyClass()) | |
'repr' | |
>>> str(MyClass()) | |
'str' | |
>>> str([MyClass()]) | |
'[repr]' | |
>>> repr([MyClass()]) | |
'[repr]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment