import ast


def literal_eval(string):
    """
    Evaluate an expression into a Python literal structure.
    """
    try:
        return ast.literal_eval(string)
    except (ValueError, SyntaxError):
        return string