Returns a string from code that contains a repr of the string

def unquote_string(code):
    """Returns a string from code that contains a repr of the string"""

    scode = code.strip()
    assert scode[-1] in ["'", '"']
    assert scode[0] in ["'", '"'] or scode[1] in ["'", '"']

    return ast.literal_eval(scode)