◐ Shell
clean mode source ↗

Message 144126 - Python tracker

Yes, that's intentional.  When use of __int__ was deprecated, a bug report popped up from someone who wanted to be able to have their own objects treated as integers for the purposes of struct.pack.  (I don't recall which issue;  Meador, do you remember?)  So we added use of __index__ at that point.

I think __index__ is the right interface for something to expose if it wants to be usable as an integer, and this usage is consistent with the original __index__ PEP.