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
- Uses callability to connect object inspection with sorting keys and class-based decorators.
- How deep it goes
- Explains callable classes and __call__ with worked examples, while deferring decorator best practices.
- Examples
- Uses a doubler function, mixed poker cards, a custom integer sorting key, and a timing decorator.
- What you can do after
- Apply callable objects as sorting keys and class-based decorators, and check objects 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.
Also covered in
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- closureA closure is a function together with access to bindings from the lexical environment in which it was created.
- inputAn input is information, a value, or an action supplied to a system, program, or computation for processing or to influence its behavior.
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
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 unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- lambdaincludes · A lambda is an expression that defines an unnamed function, specifying its parameters and body and producing a callable value.
- classincludes · A class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
- built-in functionkind of · A built-in function is a predefined callable operation supplied by a programming language, runtime, library, or execution environment.
- __call__() methodimplemented by · __call__() is a Python special method that defines the behavior of an object when invoked with function-call syntax.
Questions about callable
What is callable?
A callable is an object that can be invoked using function-call syntax.
Which Manning books explain callable?
Python How-To, The Well-Grounded Rubyist, Fourth Edition, Python Workout, Second Edition, C++ Concurrency in Action, Second Edition and Learn C++ by Example.
What should I know before learning callable?
Manning books that teach callable usually introduce function, closure, input and Python first.
What kinds of callable are there?
Kinds of callable include std::packaged_task, function, lambda and class.
What is callable a kind of?
Callable is a kind of built-in function. A built-in function is a predefined callable operation supplied by a programming language, runtime, library, or execution environment.
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.




