The callable() function in python is part of its standard library which returns true if the object is callable and returns false if it is not.The object itself should have a call method to be callable. For example if we just declare a variable with value, it is not callable, but if we declare a function then it becomes callable.
Callable Object
Below we declare a function which is callable. That can be verified by actually making a call to the function, as well as checking through the callable function.
Example
def func_callable(): x = 3 y = 5 z = x^y return z # an object is created of Geek() res = func_callable print(callable(res)) print(res) # Call and use the function final_res=func_callable() print(final_res)
Output
Running the above code gives us the following result −
True 6
Not callable()
Here we see the same program as above but without using any functions. We just use some variables for calculations. When the results are nor printed we see that the variable values are not callable.
Example
x = 3 y = 5 z = x^y print(callable(z)) print(z)
Output
Running the above code gives us the following result −
False 6