def normalize_party(header):

    regex = re.compile(
        r'.*(\bparty\b|party.*code|candidate(_|\s+)party(_|\s)id).*',
        re.IGNORECASE)

    """
    `return filter(lambda x: regex.search(x), header)[0]`
    does the same as the below list comprehension

    """

    return filter(lambda x: regex.search(x), header)[0]
Regex examples:
dataset/ETHPy150Open openelections/openelections-core/openelex/us/wa/load.py/normalize_party