w = "TEMPLATES = ( ('index.html', 'home'), ('base.html', 'base'))"
outer = re.compile('\\((.+)\\)')
m = outer.search(w)
inner_str = m.group(1)
innerre = re.compile("\\('([^']+)', '([^']+)'\\)")
results = innerre.findall(inner_str)
for x, y in results:
    pass
Python regex: matching a parenthesis within parenthesis