[Python-checkins] cpython (2.7): #16304: clarify match objects docs. Initial patch by Jan Duzinkiewicz.
ezio.melotti
python-checkins at python.org
Sun Nov 4 06:00:19 CET 2012
http://hg.python.org/cpython/rev/dc96df8556d8
changeset: 80232:dc96df8556d8
branch: 2.7
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Sun Nov 04 06:46:28 2012 +0200
summary:
#16304: clarify match objects docs. Initial patch by Jan Duzinkiewicz.
files:
Doc/library/re.rst | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -797,9 +797,16 @@
.. 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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list