callable()
callable(object) Returns:
bool · Updated March 13, 2026 · Built-in Functions built-in type-checking objects
The callable() function checks whether an object appears callable — that is, whether you could attempt to invoke it with the call operator (). It returns True if the object appears callable, and False otherwise.
Note: callable() returning True does not guarantee the object will actually execute without error when called. It only checks if the object has a __call__ method.
Syntax
callable(object)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
object | any | — | Any Python object to check for callability |
Examples
Basic usage
def greet():
return "Hello"
x = 5
print(callable(greet)) # True - functions are callable
print(callable(x)) # False - integers are not callable
Checking built-in functions
print(callable(print)) # True
print(callable(len)) # True
print(callable("hello")) # False - strings are not callable
Checking classes and instances
class Greeter:
def __call__(self):
return "Hello!"
print(callable(Greeter)) # True - classes are callable
print(callable(Greeter())) # True - instances with __call__ are callable
Checking methods
class Counter:
def __init__(self):
self.count = 0
def increment(self):
self.count += 1
obj = Counter()
print(callable(obj.increment)) # True - bound methods are callable
Common Patterns
Validating callbacks
def process_items(items, callback):
if not callable(callback):
raise TypeError(f"Expected callable, got {type(callback).__name__}")
return [callback(item) for item in items]
# This works
result = process_items([1, 2, 3], lambda x: x * 2)
print(result) # [2, 4, 6]
# This raises TypeError
result = process_items([1, 2, 3], "not a function")
Duck typing with callable checks
def execute_action(obj):
if callable(obj):
return obj()
else:
return obj
print(execute_action(lambda: "executed")) # "executed"
print(execute_action(42)) # 42
When callable() Returns True
These are callable in Python:
- Functions (def and lambda)
- Classes (calling them creates instances)
- Instances with
__call__method - Methods (bound and unbound)
- Built-in functions and methods
When callable() Returns False
These are not callable:
- Basic types:
int,str,float,bool,list,dict,tuple,set - Most built-in objects that don’t define
__call__ None
Caveat
class NotActuallyCallable:
def __init__(self):
pass
obj = NotActuallyCallable()
print(callable(obj)) # False - no __call__ method
# But you can still try to call it and get an error
try:
obj() # TypeError: 'NotActuallyCallable' object is not callable
except TypeError as e:
print(f"Error: {e}")
See Also
- built-in::isinstance — check object types
- built-in::type — get object’s type
- built-in::hasattr — check if object has specific attributes