Search code examples
pythoncallable

statement "foo is callable" return false (with foo is a function)


def foo():
    pass

a function is a callable object, so:

callable(foo) # return "True"

but

foo is callable # return "False"

So, callable in foo is callable means?


Solution

  • callable is a function that tests if its argument can be called. Either because it is a function or because it is an object with a __call__ method.

    foo is callable tests if foo and callable are the same object which they are not.