convert a object to string

def to_str(obj):
    """
    convert a object to string
    """
    if isinstance(obj, str):
        return obj
    if isinstance(obj, unicode):
        return obj.encode('utf-8')
    return str(obj)