Python callable() Function: Check Callables with Examples

The Python callable function, callable(obj), returns True when you can put parentheses after an object and call it, and False when you can’t. Functions, methods, lambdas and classes are callable; numbers, strings and lists aren’t:

callable(len)    # True
callable(49.99)  # False

Every output on this page comes from my own runs on Python 3.12.5, with prices and fees as the sample data.

In this tutorial, we’ll test common objects, make a class instance callable with __call__, guard a callback, and look at what a True result doesn’t promise.

How does the Python callable() function work?

callable() is one of the built-in functions in Python, so there’s nothing to import. It takes one object and checks whether that object supports the call syntax:

def sales_tax(amount):
    return round(amount * 0.0725, 2)

checks = {
    "sales_tax (function)": sales_tax,
    "lambda": lambda x: x * 2,
    "len (built-in)": len,
    "str (class)": str,
    "'str'.upper (method)": "Austin".upper,
    "49.99 (float)": 49.99,
    "'Austin' (string)": "Austin",
    "[1, 2] (list)": [1, 2],
}
for label, obj in checks.items():
    print(f"{label:<24} {callable(obj)}")

Output:

sales_tax (function)     True
lambda                   True
len (built-in)           True
str (class)              True
'str'.upper (method)     True
49.99 (float)            False
'Austin' (string)        False
[1, 2] (list)            False
Command Prompt output of Python callable() returning True for a function, lambda, len, str and a bound method, and False for a float, string and list
Functions, the lambda, len, the str class and a bound method print True; the float, string and list print False.

Notice that str is callable because it’s a class, while the string 'Austin' isn’t. If you’re new to writing your own, start with how to define a function in Python.

callable() with classes, instances and __call__

A class is always callable, since calling it builds an instance through its constructor. An instance is callable only when its class defines __call__:

class Discount:
    def __init__(self, percent):
        self.percent = percent

    def __call__(self, price):
        return round(price * (1 - self.percent / 100), 2)

class Customer:
    def __init__(self, name):
        self.name = name

spring_sale = Discount(15)
megan = Customer("Megan Bowen")

print("Discount class:   ", callable(Discount))
print("spring_sale obj:  ", callable(spring_sale))
print("Customer class:   ", callable(Customer))
print("megan obj:        ", callable(megan))
print("Sale price:       ", spring_sale(80.00))

Output:

Discount class:    True
spring_sale obj:   True
Customer class:    True
megan obj:         False
Sale price:        68.0
Command Prompt output of Python callable() on a Discount class with __call__, its instance, a Customer class and a Customer instance
Both classes are callable, but only the Discount object is; it returns 68.0 for an 80.00 price.

I use this pattern for configurable rules, like a discount that remembers its percentage. Callable objects also power class-based decorators in Python.

Check a callback with callable() before you call it

The most practical use is validating a function argument. When you pass a function as a parameter in Python, a quick check gives a clear error instead of a confusing one later:

def apply_fee(total, fee=None):
    if fee is None:
        return total
    if not callable(fee):
        raise TypeError(f"fee must be callable, got {type(fee).__name__}")
    return round(total + fee(total), 2)

def card_fee(total):
    return total * 0.029 + 0.30

print(apply_fee(120.00))                  # no fee
print(apply_fee(120.00, card_fee))        # function as the fee
print(apply_fee(120.00, lambda t: 5.00))  # flat fee
try:
    apply_fee(120.00, 5.00)               # passed a number by mistake
except TypeError as err:
    print("TypeError:", err)

Output:

120.0
123.78
125.0
TypeError: fee must be callable, got float

Both the named function and the lambda work, and the stray number fails right away with a message that says what went wrong.

Why doesn’t a True result guarantee the call will work?

callable() only answers whether the object can be called at all. It doesn’t check arguments, so a function called with the wrong ones still fails. A False result is different: that call can never succeed.

def ship_cost(weight_lb, zone):
    return 4.50 + weight_lb * 0.75 * zone

print(callable(ship_cost))       # True, it's a function
try:
    ship_cost(3)                 # ...but this call is still wrong
except TypeError as err:
    print("TypeError:", err)

point = (30.27, -97.74)
print(callable(point))           # False: calling it will always fail
try:
    point(0)
except TypeError as err:
    print("TypeError:", err)

Output:

True
TypeError: ship_cost() missing 1 required positional argument: 'zone'
False
TypeError: 'tuple' object is not callable
Command Prompt output showing Python callable() returning True for a function that still raises TypeError, and False for a tuple that is not callable
The function passes the check but fails with a missing-argument TypeError; the tuple fails the check and its call raises “‘tuple’ object is not callable”.

That last message usually means a variable shadowed a function name. My guide to fixing “tuple object is not callable” in Python walks through the causes.

Which Python versions include callable()?

Python 3.0 removed callable(), and Python 3.2 brought it back, so every current Python 3 release has it. On those old versions people wrote hasattr(obj, "__call__") instead; today callable() is the clearer choice.

Callables lead naturally into a few more function topics on the site:

Frequently asked questions

What does callable() return in Python?

It returns True if the object can be called with parentheses, otherwise False.

Is a class callable in Python?

Yes. Calling a class creates an instance, so callable(SomeClass) is always True.

How do I make an object callable?

Define a __call__ method in its class. Instances of that class then return True.

Can callable() return True and the call still fail?

Yes. It doesn’t check arguments, so a wrong argument count still raises TypeError.

Is callable() the same as hasattr(obj, ‘__call__’)?

They usually agree, but callable() is the built-in, readable way to ask the question.

Where is callable() documented?

See callable() in the Python docs.