def parse_p(str):
    "Parse the power part of a polynomial string term"
    pat = re.compile('x\^?(\d)?')
    if not str: return 0
    res = pat.findall(str)[0]
    if not res: return 1
    return int(res)
Parse the power part of a polynomial string term
recipes/Python/362193_Manipulate_simple_polynomials/recipe-362193.py