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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -