[Python-3000] Droping find/rfind? (original) (raw)
BJörn Lindqvist bjourne at gmail.com
Wed Aug 23 23:01:23 CEST 2006
- Previous message: [Python-3000] Droping find/rfind?
- Next message: [Python-3000] Droping find/rfind?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/23/06, Josiah Carlson <jcarlson at uci.edu> wrote:
or even
index = 0 while 1: index = text.find(..., index) if index == -1: break ... compared with index = 0 while 1: try: index = text.index(..., index) except ValueError: break ...
You are supposed to use the in operator:
index = 0 while 1: if not "something" in text[index:]: break
IMHO, removing find() is good because index() does the same job without violating the Samurai Principle (http://c2.com/cgi/wiki?SamuraiPrinciple). It would be interesting to see the patch that replaced find() with index(), did it really make the code more cumbersome?
-- mvh Björn
- Previous message: [Python-3000] Droping find/rfind?
- Next message: [Python-3000] Droping find/rfind?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]