def METHOD_NAME(input_, encoding="utf-8", errors="replace"):
    """Convert objects to string, encodes to the given encoding
    :rtype: str
    >>> to_str('a')
    b'a'
    >>> to_str(u'a')
    b'a'
    >>> to_str(b'a')
    b'a'
    >>> class Foo(object): __str__ = lambda s: u'a'
    >>> to_str(Foo())
    'a'
    >>> to_str(Foo)
    "<class 'python_utils.converters.Foo'>"
    """
    if isinstance(input_, bytes):
        pass
    else:
        if not hasattr(input_, "encode"):
            input_ = str(input_)
        input_ = input_.encode(encoding, errors)
    return input_