line = '{2}*{3}^2'
factorseq_dict = [('2', 'NAME1'), ('3', 'NAME2')]
dict_ = dict(factorseq_dict)
re.sub('\\{(\\d+)\\}', lambda m: '{' + dict_[m.group(1)] + '}', line)
Compare and replace items in a string