This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients Dennis Sweeney, apostofes, steven.daprano
Date 2022-04-04.17:33:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Perhaps what you want is inspect.isroutine ?

I agree with Dennis that the isfunction test is for **Python** (def or lambda) functions, not builtins. The docstring for the* methods make promises about what attributes an object will have:

def isbuiltin(object):
    """Return true if the object is a built-in function or method.
    Built-in functions and methods provide these attributes:
        __doc__         documentation string
        __name__        original name of this function or method
        __self__        instance to which a method is bound, or None"""

def isfunction(object):
    """Return true if the object is a user-defined function.
    Function objects provide these attributes:
        __doc__         documentation string
        __name__        name with which this function was defined
        __code__        code object containing compiled function bytecode
        __defaults__    tuple of any default values for arguments
        __globals__     global namespace in which this function was defined
        __annotations__ dict of parameter annotations
        __kwdefaults__  dict of keyword only parameters with defaults"""

def (and lambda) functions have a different API from builtin_function_or_method objects. They should be kept separate.
Date User Action Args
2022-04-04 17:33:18steven.dapranosetrecipients: + steven.daprano, Dennis Sweeney, apostofes
2022-04-04 17:33:18steven.dapranosetmessageid: <>
2022-04-04 17:33:18steven.dapranolinkissue47214 messages
2022-04-04 17:33:18steven.dapranocreate