def to_string(thing):
try:<EOL><INDENT>return str(thing)<EOL><DEDENT>except UnicodeEncodeError:<EOL><INDENT>return thing.encode('<STR_LIT:ascii>', '<STR_LIT:replace>')<EOL><DEDENT>
coverts an object to string

        >>> to_string(1)
        '1'
        >>> to_string([])
        '[]'
        >>> to_string(u"a")
        'a'
        >>> to_string(None)
        'None'
        >>> to_string(object())
        '<object ...>'