]> granicus.if.org Git - python/commitdiff
#16304: clarify match objects docs. Initial patch by Jan Duzinkiewicz.
authorEzio Melotti <ezio.melotti@gmail.com>
Sun, 4 Nov 2012 04:46:28 +0000 (06:46 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Sun, 4 Nov 2012 04:46:28 +0000 (06:46 +0200)
Doc/library/re.rst

index e6e20d62d2be79b0e5e4bd64d5f9a3dbbd42225c..1af4cf2011d0ddea4b032a2cb19049991cc4922a 100644 (file)
@@ -797,9 +797,16 @@ Match Objects
 
 .. class:: MatchObject
 
-   Match Objects always have a boolean value of :const:`True`, so that you can test
-   whether e.g. :func:`match` resulted in a match with a simple if statement.  They
-   support the following methods and attributes:
+   Match objects always have a boolean value of ``True``.
+   Since :meth:`~regex.match` and :meth:`~regex.search` return ``None``
+   when there is no match, you can test whether there was a match with a simple
+   ``if`` statement::
+
+      match = re.search(pattern, string)
+      if match:
+          process(match)
+
+   Match objects support the following methods and attributes:
 
 
    .. method:: MatchObject.expand(template)