A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/061242.html below:

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

[Python-Dev] Please comment on PEP 357 -- adding nb_index slot to PyNumberMethods [Python-Dev] Please comment on PEP 357 -- adding nb_index slot to PyNumberMethodsArmin Rigo arigo at tunes.org
Fri Feb 17 17:29:32 CET 2006
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4