def METHOD_NAME(object, encoding=None):
    """Get a unicode safe string representation of an object."""
    if isinstance(object, str):
        if encoding is None:
            return object
        return object.encode(encoding)
    if isinstance(object, tuple):
        s = ["("]
        for item in object:
            s.append(METHOD_NAME(item))
            s.append(", ")
        s.append(")")
        return "".join(s)
    if isinstance(object, list):
        s = ["["]
        for item in object:
            s.append(METHOD_NAME(item))
            s.append(", ")
        s.append("]")
        return "".join(s)
    if isinstance(object, dict):
        s = ["{"]
        for item in list(object.items()):
            s.append(METHOD_NAME(item[0]))
            s.append(" = ")
            s.append(METHOD_NAME(item[1]))
            s.append(", ")
        s.append("}")
        return "".join(s)
    try:
        return str(object)
    except Exception:
        return str(object)