Message230994
Documentation says:
> Match objects always have a boolean value of True. Since match() and
> 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)
What happens:
blah = <_sre.SRE_Match object; span=(0, 28), match='<BR>Nov. 10, 08:16:09 PM EST'>
if blah == True:
print("True")
if blah:
print('blah True')
blah True
///
Blah is not True
One suggestion: instead, the passage above should say “evaluates true in a boolean context”. |
|
Date |
User |
Action |
Args |
2014-11-11 01:26:04 | crkirkwood | set | recipients:
+ crkirkwood, docs@python |
2014-11-11 01:26:03 | crkirkwood | set | messageid: <1415669163.97.0.11938367664.issue22843@psf.upfronthosting.co.za> |
2014-11-11 01:26:03 | crkirkwood | link | issue22843 messages |
2014-11-11 01:26:03 | crkirkwood | create | |
|