[Python-ideas] Deprecate str.find
Ethan Furman
ethan at stoneleaf.us
Sun Jul 17 03:40:35 CEST 2011
Raymond Hettinger wrote:
> This thread has lost contact with reality. It started with the
> reasonable observation that many uses of str.find could
> be replaced with a simple test using the in-operator.
>
> Now, the thread is venturing into the typical python-ideas
> world of making-up random use cases and APIs. Something
> like str.find() is in many languages and it is definitely not the
> norm for them to have found a need to both be able to
> return -1 or to supply a default value.
Nick's proposal was to enhance str.index(), not string.find(); Having
str.index() accept a value to return on failure instead of raising an
exception means it could do both jobs, and would also make it much less
likely to wrongly use the failure return value of -1 from str.find()
which is, unfortunately, a legitimate index value.
~Ethan~
More information about the Python-ideas
mailing list