On Wed, Oct 13, 2021 at 4:56 PM Victor Stinner
Honestly, I don't understand well the difference between __int__() and __index__().
* https://docs.python.org/dev/reference/datamodel.html#object.__int__ * https://docs.python.org/dev/reference/datamodel.html#object.__index__
If you want to index a list or array 'a' with index 'i', and i is not an int already, we try to convert it to int using __index__. This should fail for floats, since a[3.14] is a bug. OTOH, int(x) where x is a float should work, and that's where __int__ is used. And int(s) where s is a string should also work, so int() can't call __trunc__ (as was explained earlier in the thread). -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...