Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type
Rick Wotnaz
desparn at wtf.com
Fri Aug 26 07:20:33 EDT 2005
Bryan Olson <fakeaddress at nowhere.org> wrote in
news:3ErPe.853$sV7.65 at newssvr21.news.prodigy.com:
> Steve Holden asked:
> > Do you just go round looking for trouble?
>
> In the course of programming, yes, absolutly.
>
> > As far as position reporting goes, it seems pretty clear that
> > find() will always report positive index values. In a
> > five-character string then -1 and 4 are effectively
> > equivalent.
> >
> > What on earth makes you call this a bug?
>
> What you just said, versus what the doc says.
>
> > And what are you proposing that
> > find() should return if the substring isn't found at all?
> > please don't suggest it should raise an exception, as index()
> > exists to provide that functionality.
>
> There are a number of good options. A legal index is not one of
> them.
>
>
Practically speaking, what difference would it make? Supposing find
returned None for not-found. How would you use it in your code that
would make it superior to what happens now? In either case you
would have to test for the not-found state before relying on the
index returned, wouldn't you? Or do you have a use that would
eliminate that step?
--
rzed
More information about the Python-list
mailing list