[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
Alex Martelli
aleaxit at gmail.com
Fri Feb 10 02:26:45 CET 2006
On 2/9/06, Travis E. Oliphant <oliphant.travis at ieee.org> wrote:
...
> 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.
Shouldn't that new API function (whatever its name) also be somehow
exposed for easy access from Python code? I realize new builtins are
unpopular, so a builtin 'asindex' might not be appropriate, but
perhaps operator.asindex might be. My main point is that I don't think
we want every Python-coded sequence to have to call x.__index__()
instead.
Alex
More information about the Python-Dev
mailing list