FEEDBACK WANTED: Type/class unification
Dylan Thurston
dpt at abel.math.harvard.edu
Thu Aug 9 17:17:01 EDT 2001
In article <14665424.k6j6fTUFtl at lunix.schabi.de>, Markus Schaber wrote:
>Jeff Shannon <jeff at ccvcorp.com> schrub:
>>> With the automatic turning to 0/maxint, they even are limited to
>>> non-negative integers. So it is impossible to use any form of
>>> negative indexes, which sometimes would be nice when dealing with
>>> coordinates.
>>
>> Um.... you *can* use negative values in slices:
>>
>>>>> mylist = [1, 2, 3, 4]
>>>>> mylist[-2:-1]
>> [3]
>>>>> mylist [:-2]
>> [1, 2]
>
>Yes - but this means "count from the other end" instead of "go
>backwards from index 0"
Only if you use the broken __getslice__ interface. If you use the
__getitem__ interface (passed a slice object) you can do whatever you
want.
--Dylan Thurston
More information about the Python-list
mailing list