[Python-ideas] Deprecate str.find

Guido van Rossum guido at python.org
Fri Jul 15 18:38:47 CEST 2011


On Fri, Jul 15, 2011 at 9:12 AM, Mike Graham <mikegraham at gmail.com> wrote:
> It isn't necessarily an error if the substring is not in the string
> (though it sometimes is), but it is an exceptional case. Python uses
> exceptions pretty liberally most places -- it isn't necessarily an
> error if an iterator is exhausted or if float("4.2 bad user input") is
> called or if BdbQuit was raised. In these cases, an exception can be
> perfectly expected to indicate that what happened is different from
> the information used in a return value.

This smells a bit like uncalled-for religion. Remember that readline()
returns an empty string at the end of the file instead of raising an
exception, and IMO that makes it the better API.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list