"Ricardo Aráoz" <[EMAIL PROTECTED]> wrote
>>From Python 2.5 documentation :
>
> index( sub[, start[, end]])
> Like find(), but raise ValueError when the substring is not found.
As opposed to find() which returns -1 when the string is
not found. That means you can use try/except with
index but must check for -1 with find:
if 'foo'.find('q') == -1:
print 'oops!'
as opposed to
try: 'foo'.index('q')
except ValueErrror: print 'oops!'
Which style is best will depend on what you are doing.
HTH,
Alan g
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor