[Python-checkins] cpython (3.1): Add a note to the str.find doc to suggest the use of the "in" operator.

ezio.melotti python-checkins at python.org
Mon May 9 03:00:58 CEST 2011


http://hg.python.org/cpython/rev/e4acbe2c8164
changeset:   69950:e4acbe2c8164
branch:      3.1
parent:      69942:92bc1518f20d
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Mon May 09 03:54:30 2011 +0300
summary:
  Add a note to the str.find doc to suggest the use of the "in" operator.

files:
  Doc/library/stdtypes.rst |  9 +++++++++
  1 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -883,6 +883,15 @@
    *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)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list