Jul-21-2020, 09:37 AM
You're right. If it's an container, the
Example:
repr
of the elements is printed.Example:
Output:In [1]: class Foo:
...: def __str__(self):
...: return "__"
...:
In [2]: print([Foo()] * 10)
[<__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>, <__main__.Foo object at 0x7f60b712ccd0>]
In [3]: class Foo:
...: def __str__(self):
...: return "__"
...: __repr__ = __str__
...:
In [4]: print([Foo()] * 10)
[__, __, __, __, __, __, __, __, __, __]
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!