<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def safestr(value):
    '''Ensure type to string serialization'''
    if not value or isinstance(value, (int, float, bool, long)):
        return value
    elif isinstance(value, (date, datetime)):
        return value.isoformat()
    else:
        return unicode(value)