kuroko/test/testStrReprOrdering.krk

19 lines
414 B
Python
Raw Normal View History

2022-08-06 06:20:04 +03:00
# Emulate the old behavior of method.__repr__ when printing,
# which called repr() on the receiver...
def __str__(self):
return f'<bound method {self.__qualname__} of {self.__self__!r}>'
method.__str__ = __str__
class Foo(object):
def __str__(self):
return '<str>'
def __repr__(self):
return '<repr>'
print('Foo:',Foo())
print(str(Foo()))
print(repr(Foo()))
print(Foo().__str__)
print(Foo().__repr__)