call the function re.compile with an argument raw string "^\s+.*context\s+((?:"[^"]*?")|(?:'[^']*?'))\s*", substitute the result for context_re.
context_re = re . compile ( r"""^\s+.*context\s+((?:"[^"]*?")|(?:'[^']*?'))\s*""" )