Another Wart! string.find() [ was: namespace issue? ]
Chris Barker
chrishbarker at home.net
Fri Jun 22 13:15:23 EDT 2001
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.
YEECCHHH!!!
Never raise an exception for a perfectly normal, it will happen all the
time event. I do like the return None option however. Returning -1 was
an unfortunate choice for two reasons:
it is not a false value
it is a valid index into a string
This is all kind of useless discussion however as string.find is in far
too much code as it is. Besides, it really isn't all that bad anyway.
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker at home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
More information about the Python-list
mailing list