This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients docs@python, r.david.murray, serhiy.storchaka, steven.daprano, vrutsky
Date 2012-10-23.22:23:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351031006.09.0.64673012961.issue16304@psf.upfronthosting.co.za>
In-reply-to
Content
I don't think the relevant information -- that re match and search return None in the case of no match -- is that distant from the paragraph quoted. This fact is already mentioned FOUR times in the page, in each of the re.match, re.search functions and regex.match, regex.search methods, plus implied by the helper function used in the examples.

Personally I think no change is required, but if the docs are going to be changed, I recommend going all the way and showing the usual re idiom with an example:

Match Objects always have a boolean value of ``True``.  Since ``None`` (which has a boolean value of ``False``) is returned when there is no match, you can test whether there was a match with a simple ``if`` statement. For example::

mo = re.search(pattern, string)
if mo:
    process(mo)
History
Date User Action Args
2012-10-23 22:23:26steven.dapranosetrecipients: + steven.daprano, r.david.murray, docs@python, vrutsky, serhiy.storchaka
2012-10-23 22:23:26steven.dapranosetmessageid: <1351031006.09.0.64673012961.issue16304@psf.upfronthosting.co.za>
2012-10-23 22:23:26steven.dapranolinkissue16304 messages
2012-10-23 22:23:25steven.dapranocreate