Message173641
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) |
|
Date |
User |
Action |
Args |
2012-10-23 22:23:26 | steven.daprano | set | recipients:
+ steven.daprano, r.david.murray, docs@python, vrutsky, serhiy.storchaka |
2012-10-23 22:23:26 | steven.daprano | set | messageid: <1351031006.09.0.64673012961.issue16304@psf.upfronthosting.co.za> |
2012-10-23 22:23:26 | steven.daprano | link | issue16304 messages |
2012-10-23 22:23:25 | steven.daprano | create | |
|