See PEP 357: Allowing Any Object to be Used for Slicing.
The
nb_intmethod is used for coercion and so means something fundamentally different than what is requested here. This PEP proposes a method for something that can already be thought of as an integer communicate that information to Python when it needs an integer. The biggest example of why usingnb_intwould be a bad thing is that float objects already define thenb_intmethod, but float objects should not be used as indexes in a sequence.
Edit: It seems that it was implemented in Python 2.5.
Answer from Alok Singhal on Stack OverflowVideos
See PEP 357: Allowing Any Object to be Used for Slicing.
The
nb_intmethod is used for coercion and so means something fundamentally different than what is requested here. This PEP proposes a method for something that can already be thought of as an integer communicate that information to Python when it needs an integer. The biggest example of why usingnb_intwould be a bad thing is that float objects already define thenb_intmethod, but float objects should not be used as indexes in a sequence.
Edit: It seems that it was implemented in Python 2.5.
I believe you'll find the answer in PEP 357, which has this abstract:
This PEP proposes adding an nb_index slot in PyNumberMethods and an __index__ special method so that arbitrary objects can be used whenever integers are explicitly needed in Python, such as in slice syntax (from which the slot gets its name).
2h of debuging to then find out this is the problem. I so damn hate my life. How does intellij not help there. Its highlighted in the same color. OMG I am so angry