Ben Chuanlong Du's Blog

It is never too late to learn.

Check Whether a Python Object Is Callable

In [3]:
f = lambda x: 1
In [4]:
callable(f)
Out[4]:
True
In [5]:
def fun():
    return 1
In [6]:
callable(fun)
Out[6]:
True
In [7]:
x = 1
In [8]:
callable(x)
Out[8]:
False
In [ ]:

Comments