ydhhat
ydhhat

Reputation: 391

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?

Upvotes: 1

Views: 151

Answers (1)

Dan D.
Dan D.

Reputation: 74655

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.

Upvotes: 4

Related Questions