From: Ezio Melotti Date: Mon, 9 May 2011 00:54:30 +0000 (+0300) Subject: Add a note to the str.find doc to suggest the use of the "in" operator. X-Git-Tag: v3.2.1rc1~43^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ed8c6897c2330950643fda6c6e8ee283c030311;p=python Add a note to the str.find doc to suggest the use of the "in" operator. --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 7621eef4ae..2e3e18feac 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -883,6 +883,15 @@ functions based on regular expressions. *start* and *end* are interpreted as in slice notation. Return ``-1`` if *sub* is not found. + .. note:: + + The :meth:`~str.find` method should be used only if you need to know the + position of *sub*. To check if *sub* is a substring or not, use the + :keyword:`in` operator:: + + >>> 'Py' in 'Python' + True + .. method:: str.format(*args, **kwargs)