Python callable()

Python callable() builtin function checks if given object is callable or not. callable() returns True if the argument passed to it is callable, else it returns false.

In this tutorial, we will learn about the syntax of Python callable() function, and learn how to use this function with the help of examples.

Syntax

The syntax of callable() function is

callable(object)

where

ParameterRequired/OptionalDescription
objectRequiredThe object which has to be checked if callable or not.

Returns

The function returns boolean value.

ADVERTISEMENT

Examples

1. callable(Function)

In this example, we will define a function myFunc and pass this function as argument to callable() builtin function. Since a function is callable, callable(myFunc) should return True.

Python Program

def myFunc():
    print('hello wolrd!')

result = callable(myFunc)
print(f'Return Value: {result}')
Try Online

Output

Return Value: True

2. callable(variable)

In this example, we will give an integer value in variable x as argument to callable() function. Since, integer value is not callable, callable(x) should return False.

Python Program

x = 10
result = callable(x)
print(f'Return Value: {result}')
Try Online

Output

Return Value: False

3. callable(Builtin Function)

In this example, we will pass a builtin function, say list, as argument to callable() function. Since a builtin function is callable, callable(list) should return True.

Python Program

result = callable(list)
print(f'Return Value: {result}')
Try Online

Output

Return Value: True

Conclusion

In this Python Tutorial, we have learnt the syntax of Python callable() builtin function, and also learned how to use this function, with the help of Python example programs.