import re
m = re.match('foo', 'bar')# pattern does not match string
if m is not None: m.group()# (1-line version of ifclause)
m = re.match('foo', 'food on the table') # match succeeds
print m.group()
print re.match('foo', 'food on the table').group()