19 lines
414 B
Python
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__)
|