Georg Brandl wrote: > Bernhard Herzog wrote: >> "Travis E. Oliphant" <[EMAIL PROTECTED]> writes: >> >>> 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). >> So int objects will not have an __index__ method (assuming that ints >> won't return a different but equal int object). However: >> >>> 4) A new operator.index(obj) function will be added that calls >>> equivalent of obj.__index__() and raises an error if obj does not >>> implement the special method. >> So operator.index(1) will raise an exception. I would expect >> operator.index to be implemented using PyNumber_index. > > I'd expect that __index__ won't be called on an int in the first place.
The PEP has been updated to cover adding the __index__ slot to int/long so that "one check finds all". The slot will just get bypassed for ints and longs by a lot of the C code in the interpreter. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ 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