[Python-3000] Droping find/rfind?

Delaney, Timothy (Tim) tdelaney at avaya.com
Thu Aug 24 04:05:08 CEST 2006


Nick Coghlan wrote:

> I also like Josiah's idea of replacing find() with a search() method
> that returned an iterator of indices, so that you can do:
> 
> for idx in string.search(sub):
>     # Process the indices (if any)

Need to be careful with this - the original search proposal returned a
list, which could be tested for a boolean value - hence:

    if not string.search(sub):
        pass

but if an iterator were returned, I think we would want to be able to
perform the same test i.e. search would have to return an iterator that
had already performed the initial search, with __nonzero__ reflecting
the result of that search. I do think that returning an iterator is
better due to the fact that most uses of search() would only care about
the first returned index.

Tim Delaney


More information about the Python-3000 mailing list