def to_repr(value, ctx):
    """
    Converts a value back to its representation form, e.g. x -> "x"
    """
    as_string = to_string(value, ctx)

    if isinstance(value, str) or isinstance(value, datetime.date) or isinstance(value, datetime.time):
        as_string = as_string.replace('"', '""')  # escape quotes by doubling
        as_string = '"%s"' % as_string

    return as_string
Converts a value back to its representation form, e.g. x -> "x"