Another Wart! string.find() [ was: namespace issue? ]
donn at u.washington.edu
Fri Jun 22 21:16:08 CEST 2001
Quoth Chris Barker <chrishbarker at home.net>:
| Andrew Dalke wrote:
|> index(s, sub [,start [,end]]) -> int
|> Return the lowest index in s where substring sub is found,
|> such that sub is contained within s[start,end]. Optional
|> arguments start and end are interpreted as in slice notation.
|> Raise ValueError if not found.
| Never raise an exception for a perfectly normal, it will happen all the
| time event.
Sure, but always raise an exception if the caller isn't going
to account for this perfectly normal event. Exceptions aren't
Similar exception usage is actually somewhat idiomatic in Python -
i = x.find('#')
x = x[:i]
v = x[k]
Donn Cave, donn at u.washington.edu
More information about the Python-list