New submission from Clayton Kirkwood:
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”.
----------
assignee: docs@python
components: Documentation
messages: 230994
nosy: crkirkwood, docs@python
priority: normal
severity: normal
status: open
title: doc error: 6.2.4. Match Objects
type: resource usage
versions: Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22843>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com