I wondered why list.__str__()
stringifies each element by __repr__()
in follow case:
class A:
def __repr__(self):
return 'repr()'
def __str__(self):
return 'str()'
print(str([A(), A()])) # output: [repr(), repr()]
First, I tried running above code in other python interpreter and get same result.
Then I googled whether this behavior has been defined in the spec or not, however I couldn't find any document about list.__str__()
's procedure. I found this document, but it's not enough. It doesn't defined any procedure.
Do any specifications for list.__str__
exist or not?