def hasmethod(obj, methodname):
    """Does ``obj`` have a method named ``methodname``?"""

    if not hasattr(obj, methodname):
        return False
    method = getattr(obj, methodname)
    return callable(method)
Does ``obj`` have a method named ``methodname``?
stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/helpers/hasmethod.py