New submission from Martin Horcicka:
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.
----------
components: Documentation, Library (Lib)
messages: 56149
nosy: horcicka
severity: normal
status: open
title: Match object should be guaranteed to always be true
type: behavior
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1208>
__________________________________