[issue47214] builtin_function_or_method is also either a function or a method
New submission from Ravi Jain : the. ``` import inspect inspect.isfunction ``` does not consider a ``` builtin_function_or_method ``` as a function. for example, ``` inspect.isfunction(abs) ``` gives, ``` False ``` in the background even the builtin `abs` is a function, so shouldn't it return True? the way this check is implemented is by matching the type of a builtin_function_or_method with, ``` type(len) ``` and since, `type(len)` is `builtin_function_or_method`, so, the `inspect.isfunction` check gives False. But in my opinion, it should return True, even for builtin functions or methods. -- components: Build messages: 416664 nosy: apostofes priority: normal severity: normal status: open title: builtin_function_or_method is also either a function or a method versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue47214> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue47214] builtin_function_or_method is also either a function or a method
Ravi Jain added the comment: but `callable` returns `True` for classes with `__call__` also, it does not check whether the argument passed to it is a function or not. I want some way to return `True` for both builtin functions and Python functions, but not for classes. And similarly, some way to return `True` for both builtin methods and Python methods. Should the documentation for `inspect.isfunction` include, `this does not include builtin functions.`, and similarly for `inspect.ismethod`? Should I create a PR to add these two sentences to the documentation? -- ___ Python tracker <https://bugs.python.org/issue47214> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue47214] builtin_function_or_method is also either a function or a method
Ravi Jain added the comment: yes, I think `inspect.isroutine` does the required functionality. sorry, I did not know about it, and could not think of the word `routine` when checking for functions. -- ___ Python tracker <https://bugs.python.org/issue47214> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com