Callable
A callable is an object that can be invoked using function-call syntax.
Python How-To
callable is a Python built-in function that returns whether an object can be invoked with the call operator.
- How it is used
- Checks whether Python objects can be called and explains why functions, classes, and some instances work in callable-taking APIs.
- How deep it goes
- Defines callable and works through sorting keys and __call__-based decorators, while deferring decorator best practices.
- Examples
- Tests a doubling function, sorts poker cards with a class key, and logs execution time with a class decorator.
- What you can do after
- Build it from scratch: create a callable sorting key or class-based decorator, and check an object with callable.
The Well-Grounded Rubyist, Fourth Edition
A callable object is an object that provides a way to invoke encapsulated behavior as a function-like operation.
- How it is used
- Uses callable objects to store, pass, select, and execute behavior dynamically.
- How deep it goes
- Explains Proc creation, invocation syntax, closures, variable bindings, and method objects, while deferring exhaustive callable behavior.
- Examples
- Demonstrates Proc blocks, multiplier closures, preserved local context, counters, method binding, and alternate invocation syntax.
- What you can do after
- Apply it via Ruby Procs, lambdas, and method objects to defer, pass, select, and invoke behavior.
Read how The Well-Grounded Rubyist, Fourth Edition explains callable →
Python Workout, Second Edition
A callable is a Python object that can be invoked using call syntax with parentheses.
- How it is used
- Routes user input to functions or classes selected through keyword arguments.
- How deep it goes
- Defines callability, applies it to menu dispatch, and traces class invocation through __new__ and __init__.
- Examples
- Uses menu callbacks named func_a and func_b, plus Foo(10) as a class invocation.
- What you can do after
- Apply it by building a menu that invokes keyword-selected callables and returns their results.
C++ Concurrency in Action, Second Edition
A callable object is an object that can be invoked with function-call syntax.
- How it is used
- Passes functions, function objects, or lambdas to std::thread to specify work for a new thread.
- How deep it goes
- Explains function-object copying and a declaration-parsing pitfall, but does not detail callable internals.
- Examples
- Demonstrates a function, an operator() class, a lambda, and ambiguous thread-construction syntax.
- What you can do after
- Apply callable functions, objects, or lambdas when constructing a std::thread.
Read how C++ Concurrency in Action, Second Edition explains callable →
Learn C++ by Example
A callable is a function or function-like object that can be invoked with a specified argument list.
- How it is used
- Uses callable parameters to separate number-guessing feedback from the game's input and control flow.
- How deep it goes
- Explains callable types through std::function, lambdas, templates, and std::invocable, while deferring concepts to the next chapter.
- Examples
- Demonstrates callable feedback in a number-guessing game that reports whether guesses are too small or too big.
- What you can do after
- Apply it via std::function or constrained parameters to pass customizable feedback behavior into a C++ function.
Related concepts
- std::packaged_taskincludes · `std::packaged_task` is a C++ standard library class template that wraps a callable and stores its result in a shared state accessible through a future.
- functionincludes · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- classincludes · A class is a programming-language construct that defines a type’s structure or behavior and provides a basis for creating or representing objects.
- lambdaincludes · A lambda is a language construct that defines an unnamed function or callable, often as a value.
- callused by · A function call is an operation or expression that invokes a function or other callable, optionally supplies arguments, and initiates its execution.
- std::threadused by · A C++ standard library class that represents and manages a thread of execution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




