From 87b86c84ef2755d628969b024b103a538d8f57f2 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 9 May 2011 03:54:30 +0300 Subject: [PATCH] Add a note to the str.find doc to suggest the use of the "in" operator. --- Doc/library/stdtypes.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 64496326f77..0e32348b9b9 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -944,6 +944,15 @@ string 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)