This attribute will use for convertion classes to other types, i.e. int(MyClass) will return __convert__ result in MyClass
Example: class MyClass: def __init__(self, numer: int): self.number = number def __convert__(self, type): assert type == int # Only integer is allowed return self.number*5 # Example test = MyClass(1) test_2 = MyClass(5) print( int(test) ) # 5 print( int(test2) ) # 25 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/IOJVYBX2PXGBMJ4G4TJQ5APIQHHKSXND/ Code of Conduct: http://python.org/psf/codeofconduct/