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.

classification
Title: Match object should be guaranteed to always be true
Type: behavior Stage:
Components: Documentation, Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, martin.horcicka
Priority: normal Keywords:

Created on 2007-09-26 20:34 by martin.horcicka, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg56149 - (view) Author: Martin Horcicka (martin.horcicka) Date: 2007-09-26 20:34
Many people expect the match object from the re module to always be
true. They use it this way:

    if regexp.match(string): do_something()

Some people do not expect it and use it differently:

    if regexp.match(string) is not None: do_something()

Even in the standard library both ways are used. The first way is
simpler and nicer and thus better, in my opinion.

Current implementation of the match object (implemented as
_sre.SRE_Match object in Modules/_sre.c) seems to guarantee the trueness
(someone should check it) but in fact, there is no guarantee described
in the documentation.
msg56159 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-27 06:27
Fixed in the docs as r58270.
History
Date User Action Args
2022-04-11 14:56:27adminsetgithub: 45549
2007-09-27 06:27:09georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg56159
nosy: + georg.brandl
2007-09-26 20:34:54martin.horcickacreate