On Thu, 30 Aug 2007 09:41:00 -0700, zzbbaadd wrote:

> On Aug 30, 12:09 am, Ben Finney <[EMAIL PROTECTED]>
> wrote:
>> [EMAIL PROTECTED] writes:
>> > What's with the index() function of lists throwing an exception on not
>> > found?
>>
>> It's letting you know that the item isn't in the list. There's no
>> sensible return value from an "index" function in that condition.
> 
> for str:
> 
> find(         sub[, start[, end]])
>     Return the lowest index in the string where substring sub is
> found, such that sub is contained in the range [start, end]. Optional
> arguments start and end are interpreted as in slice notation. Return
> -1 if sub is not found.

But that is a valid index into a string!  So this may go unnoticed if one
doesn't check after every call to `str.find()`.  And that method is going
away in Python 3.0.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to