[Python-ideas] Deprecate str.find

Antoine Pitrou solipsis at pitrou.net
Fri Jul 15 18:31:29 CEST 2011


On Fri, 15 Jul 2011 12:12:33 -0400
Mike Graham <mikegraham at gmail.com> wrote:
> [...]
> Now. we can dredge up some examples where -1 is the actual value
> someone wants to use. These cases are so rare and so subtle as to make
> their use so clever I don't really see their existence as an
> advantage.
> 
> Additionally, it is unfortunate that we currently have two methods to
> do the same thing (which isn't even a super-common task) with
> different APIs. Nothing about the names "find" and "index" really
> makes clear which is which. This violates the "There should be one--
> and preferably only one --obvious way to do it." principle and makes
> the Python user need to memorize an unnecessary, arbitrary
> distinction.

While this would be a very good argument to make if we were currently
designing the str API, I don't think the benefits of suppressing
str.find outweight the burden of converting old code to use a different
idiom.

We could choose to write something about it in the documentation,
though.

Regards

Antoine.





More information about the Python-ideas mailing list