def find_parens(s):
    """Get indices of matching parantheses in a string."""
    # Source: https://stackoverflow.com/questions/29991917/indices-of-matching-parentheses-in-python
    
    toret = {}
    pstack = []

    for i, c in enumerate(s):
        if c == '(':
            pstack.append(i)
        elif c == ')':
            if len(pstack) == 0:
                raise IndexError("No matching closing parens ')' at: " + str(i) + s)
            toret[pstack.pop()] = i

    if len(pstack) > 0:
        raise IndexError("No matching opening parens '(' at: " + str(pstack.pop())+s)

    return toret