Q:

How to distinguish NoneType with regex function?

Here are two very basic examples of the problem that I am currently encountering in my work:
import re
type(re.search('(Bob)(.*)(Builder)', "Bob the Builder" , re.IGNORECASE))

returns _sre.SRE_Match and 
import re
type(re.search('(Bob)(.*)(Builder)', "the Builder" , re.IGNORECASE))

returns NoneType. How can I test for the condition whether the data type is _sre.SRE_Match or NoneType? When I try implementing the code
import re
type(re.search('(Bob)(.*)(Builder)', "the Builder" , re.IGNORECASE)) is None

it returns False when it should be returning True. What am I doing incorrect here? Thank you!

A:

type(None) is not None, it's NoneType. But you don't need type here, just use a bool: 
if re.search(....): 
  print 'found!'

