from datetime import datetime


def _get_key_value(obj, key):
    """Helper method to an attribute value, dealing
    gracefully with datetimes by converting to isoformat

    Args:
        obj: Object to retrieve value from
        key (str): Name of the attribute to retrieve.
    Returns:
        {key, value}: A key-value pair corresponding to the attribute
    """
    value = getattr(obj, key)
    if isinstance(value, datetime):
        value = value.isoformat()
    return (key, value)