1

Whenever I'm trying to print the code below I get <__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()

How do I print desired arguments using standard print function?

sultan
  • 5,978
  • 14
  • 59
  • 103

1 Answers1

1

Each class allows you to override __str__ method you would do something like this

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

    def __str__(self):
        print(f"definition={self.definition}, {self.other}")
sultan
  • 5,978
  • 14
  • 59
  • 103