Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:
https://docs.python.org/3/library/inspect.html#inspect.isfunction says this: """ inspect.isfunction(object) Return True if the object is a Python function, which includes functions created by a lambda expression. """ Emphasis on the "Python function", as in, something written in Python using a `def` statement or a `lambda` expression. If isfunction returns True, you can presumably access function-specific implementation details like the functions's f.__code__ attribute. If you need to check for "anything that works as a function", you can use `callable()`: >>> callable(lambda: 2) True >>> callable(abs) True >>> def f(x): return x >>> callable(f) True I'm not an expert on the inspect module, but I'm guessing it's not worth breaking backwards-compatibility to change this behavior. Would extra emphasis in the documentation have been helpful for you, or were you mostly attempting to rely on the function's name? ---------- nosy: +Dennis Sweeney _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47214> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com