Bug in string.find; was: Re: Proposed PEP: New style indexing,was Re: Bug in slice type
Robert Kern
rkern at ucsd.edu
Tue Aug 30 06:58:20 EDT 2005
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.
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 $.
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list