liveBook · Manning

Callable

A callable is an object that can be invoked using function-call syntax.

How 5 Manning books explain it

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.

Read how Python How-To explains 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.

Read how Python Workout, Second Edition explains callable →

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.

Read how Learn C++ by Example explains callable →

Related concepts

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.