我知道在 Python Shell 中,当您键入时,>>> object它会显示该object.__repr__方法,如果您键入,>>> print(object)它也会显示该object.__str__方法。
但我的问题是,有没有一种__repr__在执行Python文件时进行打印的简短方法?
我的意思是,在 file.py 中,如果我使用print(object)它,它会显示object.__str__,如果我只是键入,object它不会显示任何内容。
我尝试过使用print(object.__repr__)但它打印<bound method object.__repr__ of reprReturnValue>
或者这是不可能的?