def _format_where(where, subj_variable, obj_variable=None):
    """
    Format WHERE clauses, including replacing ?subj and ?obj with
    unique variable names.
    """
    new_where = where.strip()
    new_where = new_where.replace("?subj", "?{}".format(subj_variable))
    if obj_variable:
        new_where = new_where.replace("?obj", "?{}".format(obj_variable))
    return new_where