On 8/23/06, Josiah Carlson <[EMAIL PROTECTED]> 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
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com