[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
Guido van Rossum
guido at python.org
Fri Feb 10 02:54:41 CET 2006
More information about the Python-Dev mailing list
Fri Feb 10 02:54:41 CET 2006
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2/9/06, Travis E. Oliphant <oliphant.travis at ieee.org> wrote: > Thomas Wouters wrote: > > I have a slight reservation about the name. On the one hand it's clear the > > canonical use will be for indexing sequences, and __index__ doesn't look > > enough like __int__ to get people confused on the difference. On the other > > hand, there are other places (in C) that want an actual int, and they could > > use __index__ too. Even more so if a PyArg_Parse* grew a format for 'the > > index-value for this object' ;) I think we should just change all the existing formats that require int or long to support nb_as_index. > There are other places in Python that check specifically for int objects > and long integer objects and fail with anything else. Perhaps all of > these should aslo call the __index__ slot. Right, absolutely. > But, then it *should* be renamed to i.e. "__true_int__". One such place > is in abstract.c sequence_repeat function. I don't like __true_int__ very much. Personally, I'm fine with calling it __index__ after the most common operation. (Well, I would be since I think I came up with the name in the first place. :-) Since naming is always so subjective *and* important, I'll wait a few days, but if nobody suggests something better then we should just go with __index__. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list