Best Division

Spread Your Knowledge

  • All topics
  • About us
  • Contact us
  • Privacy policy
  • Terms of service
  • Copyright
  • Facebook
  • Twitter
  • Instagram
  • Youtube
  • LinkedIn
  • Pinterest
  • Github
  • Tumblr

© 2026 Best Division

Python callable() Function: Check If an Object Is Callable

Python
Jayant Kumar
Jayant Kumar@jayantkumar314
PublishedJul 14, 2023
UpdatedNov 17, 2026
5 min read

The built-in callable(obj) function returns True if obj can be called like a function, and False otherwise. Functions, methods, lambdas, classes and instances of classes that define __call__ are all callable.

Use it to validate callbacks, plugins and handlers before you invoke them. A True result is not a guarantee that the call will succeed, because the arguments may still be wrong, but a False result means the call will always raise TypeError.

Table of Contents

  • Syntax and return value
  • What counts as callable
  • Making your own objects callable
  • Validating callbacks before use
  • callable versus try/except and typing
  • Frequently Asked Questions
    • Does callable return True for classes?
    • Can an object be callable and still fail when called?
    • How do I check whether an attribute is a method?
    • Is callable the same as isinstance(obj, Callable)?
  • Summary

Syntax and return value

python

The function takes one argument and returns a boolean. It was removed in Python 3.0, then restored in Python 3.2, so it is available in every current Python 3 release.

python
text

Note that str is callable because calling a class creates an instance. The built-in len is callable because it is a function implemented in C.

What counts as callable

An object is callable if its type defines a __call__ method. Python functions and methods have one built in, and every class is callable through its metaclass.

Objectcallable() result
Function, lambda, built-in functionTrue
Bound method, staticmethod result accessed on a classTrue
Class (including int, dict, your own classes)True
Instance of a class with __call__True
Number, string, list, dict, NoneFalse
ModuleFalse

Making your own objects callable

Define __call__ on a class and its instances become callable. This is useful for objects that keep state between calls, such as counters, validators or configured formatters.

python
text

Here Multiplier is callable because it is a class, and double is callable because the class defines __call__. The attribute factor is just an integer, so it is not callable.

Validating callbacks before use

The most common use is checking an argument that should be a function. Failing early with a clear message is better than a confusing error deep inside your code.

python
text

You can also use callable to accept either a value or a factory, for example a default that is computed lazily when it is a function.

python
text

callable versus try/except and typing

Python style prefers asking for forgiveness: call the object and catch TypeError. That approach has a flaw, because a TypeError raised inside the function body is indistinguishable from "not callable". Checking callable first separates the two cases.

For type hints, use collections.abc.Callable, which describes the expected signature to static checkers. It does not replace the runtime check.

python
text

Also avoid checking hasattr(obj, "__call__") in new code. callable() is shorter, clearer and checks the type, which is how Python itself finds __call__.

Frequently Asked Questions

Does callable return True for classes?

Yes. Calling a class creates an instance, so every class is callable, including built-in types such as int and list.

Can an object be callable and still fail when called?

Yes. callable only checks that a call is possible in principle. Wrong arguments or errors inside the function still raise exceptions.

How do I check whether an attribute is a method?

Use callable(getattr(obj, "name", None)). The default of None avoids an AttributeError when the attribute does not exist.

Is callable the same as isinstance(obj, Callable)?

For practical purposes, yes: isinstance(obj, collections.abc.Callable) gives the same answer. The callable() built-in is the simpler choice.

Summary

callable(obj) tells you whether Python can call an object. Functions, classes and instances with __call__ are callable, while plain data values and modules are not. Use it to validate callbacks and lazy defaults, and pair it with collections.abc.Callable in type hints.

Share