[Python-Dev] Please comment on PEP 357 -- adding nb_index slot to PyNumberMethods

Thomas Wouters thomas at xs4all.net
Fri Feb 17 17:41:11 CET 2006


On Fri, Feb 17, 2006 at 05:29:32PM +0100, Armin Rigo wrote:
> >        Where obj must be either an int or a long or another object that has the
> >        __index__ special method (but not self).

> The "anything but not self" rule is not consistent with any other
> special method's behavior.  IMHO we should just do the same as
> __nonzero__():

> * __nonzero__(x) must return exactly a bool or an int.

Yes, very much so. And in case people worry that this makes wrapping
objects harder: proxy objects (for instance) would do 'return
operator.index(self._real)'.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!


More information about the Python-Dev mailing list