[Python-ideas] Deprecate str.find
Ronny Pfannschmidt
Ronny.Pfannschmidt at gmx.de
Sat Jul 16 20:43:21 CEST 2011
On Sat, 2011-07-16 at 08:26 -0700, Raymond Hettinger wrote:
>
> On Jul 15, 2011, at 6:57 AM, Mike Graham wrote:
>
> > str.find (and bytes.find) is worse than the alternatives in every
> > way.
> > It should be explicitly deprecated in favour of str.__contains__ and
> > str.index.
> >
>
>
> Unless an API is flat out broken, deprecation is almost always a bad
> idea.
> This API has been around for a very long time, so deprecating it will
> break lots of people's code for almost zero benefit:
>
>
> http://www.google.com/codesearch#search/&q=%5C.find%5C(%20lang:%
> 5Epython$&type=cs
>
Although a quick lock over the found snippets tells,
that apparently many uses of find are indeed "ugly" code
that could be improved by use of index or __contains__
Since a DeprecationWarning seems rather intrusive,
what would be a less intrusive way to cause code-enhancement in such
places?
-- Ronny
>
>
>
> Raymond
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110716/9b3efcce/attachment.pgp>
More information about the Python-ideas
mailing list