[Python-ideas] Dunder method to make object str-like

Ethan Furman ethan at stoneleaf.us
Thu Apr 7 11:03:29 EDT 2016

On 04/07/2016 07:07 AM, Random832 wrote:

> What's __index__ for?

__index__ is a way to get an int from an int-like object without losing 
information; so it fails with values like 3.4, but should succeed with 
values like Fraction(4, 2).

__int__ is a way to convert the value to an int, so 3.4 becomes 3 (and 
and the 4/10's is lost).


More information about the Python-ideas mailing list