[Python-3000] Droping find/rfind? (original) (raw)

Josiah Carlson jcarlson at uci.edu
Thu Aug 24 04:14:08 CEST 2006


"Delaney, Timothy (Tim)" <tdelaney at avaya.com> wrote:

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.

... which is why there is a count argument, that I have recently suggested default to 1.



More information about the Python-3000 mailing list