mercredi 13 juillet 2016

How to Set Class Name? [duplicate]


This question already has an answer here:

How can I set my own class name/description so that when I print the class object, the output is the class name/description specified by me?

class XYZ:
    def __init__(self, max_depth):
        self.max_depth = max_depth

x1 = XYZ(5)
print(x1)

output: XYZ(max_depth=5)


Aucun commentaire:

Enregistrer un commentaire