[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
Travis E. Oliphant
oliphant.travis at ieee.org
Fri Feb 10 02:09:27 CET 2006
Guido van Rossum wrote:
> On 2/9/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> This is very close to acceptance. I think I'd like to see the patch
> developed and submitted to SF (and assigned to me) prior to
>> This document is placed in the public domain
> If you agree with the above comments, please send me an updated
> version of the PEP and I'll check it in over the old one, and approve
> it. Then just use SF to submit the patch etc.
I uploaded a patch to SF against current SVN. The altered code compiles
and the functionality works with classes defined in Python. I have yet
to test against a C-type that defines the method.
The patch adds a new API function int PyObject_AsIndex(obj).
This was not specifically in the PEP but probably should be. The name
could also be PyNumber_AsIndex(obj) but I was following the nb_nonzero
slot example to help write the code.
More information about the Python-Dev