[Python-3000] Droping find/rfind? (original) (raw)
Delaney, Timothy (Tim) tdelaney at avaya.com
Thu Aug 24 04:05:08 CEST 2006
- Previous message: [Python-3000] find -> index patch
- Next message: [Python-3000] Droping find/rfind?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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):
passbut 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
- Previous message: [Python-3000] find -> index patch
- Next message: [Python-3000] Droping find/rfind?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]