def as_integer(value):
    """Return the given value as an integer if possible."""
    try:
        int_value = int(value)
        if value == int_value:
            return int_value
    except Exception:
        # The value wasn't even numeric.
        pass
    return value