kuroko/test/testStrReprOrdering.krk
2022-08-06 12:20:04 +09:00

19 lines
414 B
Python

# 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__)