found, index = text.index("abc")
if found:
doSomething(index)
If you were confident that the index was in there you would do something more like this:
something = text[text.index("abc")[1]:]
(although there are clearer ways to do that)
On 8/23/06, Steven Bethard <
[EMAIL PROTECTED]> wrote:
On 8/23/06, Barry Warsaw < [EMAIL PROTECTED]> wrote:
> I agree with Tim -- if we have to get rid of one of them, let's get
> rid of index/rindex and keep find/rfind. Catching the exception is
> much less convenient than testing for -1.
Could you post a simple example or two? I keep imagining things like::
index = text.index(...)
if 0 <= index:
... do something with index ...
else:
...
which looks about the same as::
try:
index = text.index(...)
... do something with index ...
except ValueError:
...
Is it just that a lot of the else clauses are empty?
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: http://mail.python.org/mailman/options/python-3000/paul%40prescod.net
_______________________________________________ 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
