Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type

Antoon Pardon apardon at forel.vub.ac.be
Tue Aug 30 07:18:00 EDT 2005


Op 2005-08-30, Robert Kern schreef <rkern at ucsd.edu>:
> Bryan Olson wrote:
>
>>      Currently, user-defined classes can implement Python
>>      subscripting and slicing without implementing Python's len()
>>      function. In our proposal, the '$' symbol stands for the
>>      sequence's length, so classes must be able to report their
>>      length in order for $ to work within their slices and
>>      indexes.
>> 
>>      Specifically, to support new-style slicing, a class that
>>      accepts index or slice arguments to any of:
>> 
>>          __getitem__
>>          __setitem__
>>          __delitem__
>>          __getslice__
>>          __setslice__
>>          __delslice__
>> 
>>      must also consistently implement:
>> 
>>          __len__
>> 
>>      Sane programmers already follow this rule.
>
> Incorrect. Some sane programmers have multiple dimensions they need to
> index.

I don't see how that contradicts Bryan's statement.

>   from Numeric import *
>   A = array([[0, 1], [2, 3], [4, 5]])
>   A[$-1, $-1]
>
> The result of len(A) has nothing to do with the second $.

But that is irrelevant to the fact wether or not sane
programmes follow Bryan's stated rule. That the second
$ has nothing to do with len(A), doesn't contradict
__len__ has to be implemented nor that sane programers
already do.

-- 
Antoon Pardon



More information about the Python-list mailing list