Steven D'Aprano added the comment:

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)

----------
nosy: +stevenjd

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to