如何在函数内部打印 __init__() ?

How do I print an __init__() inside of a function?

每当我尝试打印下面的代码时,我都会得到 <__main__.Initial object at 0x106071ee0>:

# INITILIZATION
class Initial:
    def __init__(self, arg1, arg2, arg3, arg4, arg5):
        self.definition = arg1
        self.other = arg2
        self.present = arg3
        self.imperfect = arg4
        self.perfect = arg5


# DEFINITIONS

def salve():
    dictator = Initial("hello\n" ,"Salvete = hello (plural)\n" , None , None, None)
    print(dictator)
salve()

如何使用标准 print 函数打印所需参数?

每个 class 允许您重写 __str__ 方法,您会做这样的事情

class Initial:
    def __init__(self, arg1, arg2, arg3, arg4, arg5):
        ...

    def __str__(self):
        print(f"definition={self.definition}, {self.other}")