[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation (original) (raw)

Travis E. Oliphant oliphant.travis at ieee.org
Thu Feb 9 16:23:05 CET 2006


Adam Olsen wrote:

On 2/9/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:

Guido seemed accepting to this idea about 9 months ago when I spoke to him. I finally got around to writing up the PEP. I'd really like to get this into Python 2.5 if possible. -1 I've detailed my reasons here: http://mail.python.org/pipermail/python-dev/2006-January/059851.html In short, there are purely math usages that want to convert to int while raising exceptions from inexact results. The name index seems inappropriate for this, and I feel it would be cleaner to fix float.int to raise exceptions from inexact results (after a suitable warning period and with a trunc() function added to math.)

I'm a little confused. Is your opposition solely due to the fact that you think float's int method ought to raise exceptions and the apply_slice code should therefore use the int slot?

In theory I can understand this reasoning. In practice, however, the int slot has been used for "coercion" and changing the semantics of int(3.2) at this stage seems like a recipe for lots of code breakage. I don't think something like that is possible until Python 3k.

If that is not your opposition, please be more clear. Regardless of how it is done, it seems rather unPythonic to only allow 2 special types to be used in apply_slice and assign_slice.

-Travis



More information about the Python-Dev mailing list