python - What is the purpose of `or None` in this code? -
i've been browsing code of pyparsing
library. in there, found following fragment:
result = instring[loc] == self.firstquotechar , self.re.match(instring,loc) or none if not result: raise parseexception(instring, loc, self.errmsg, self) loc = result.end() ret = result.group()
to boil down more, understanding of result
in there is:
result = firstcharacteriscorrect(...) , self.re.match(...) or none
here don't understand: why have or none
in there?
if first character not correct, without or none
false
. if correct, regexp fails none
failed match anyway.
in either case (with false or none) if not result
right thing.
so why add or none
? missing? why none
preferable false
?
the author wants result
none
or match object. without or none
, if first test fails result
false
due short-circuiting rules.
Comments
Post a Comment