import re


def substitute(string, substitutions):
    """
    Take each key in the substitutions dict. See if this key exists
    between double curly braces in string. If so replace with value.

    Example:
    substitute("my name is {{name}}.",{version:1,name=John})
    > "my name is John"
    """
    for key, value in substitutions:
        string = re.sub(re.escape("{{" + key + "}}"), value, string)
    return string