This method searches for the first group of word characters (ie: [a-zA-Z0-9_]), returning the first matched group or None in case of failure.
Basically a and b returns the operand that has the same truth value as the whole expression.
It might sound a bit confusing but just do it in your head: If a is False, then b does not matter anymore (because False and anything will always be False), so it can return a right away.
But when a is True then only b matters, so it returns b right away without even looking.
This is a very common and very basic optimization many languages do.