Hi Travis, On Tue, Feb 14, 2006 at 08:41:19PM -0700, Travis E. Oliphant wrote: > 2) The __index__ special method will have the signature > > def __index__(self): > return obj > > 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. This ensures that there is no infinite loop in C created by a __nonzero__ that returns something that has a further __nonzero__ method. The rule that the PEP proposes for __index__ (returns anything but not 'self') is not useful, because you can still get infinite loops (you just have to work slightly harder, and even not much). We should just say that __index__ must return an int or a long. A bientot, Armin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com