Typing and Generics
typing.Callable
Annotates a callable's parameter types and return type. Use ellipsis for unspecified parameters or ParamSpec for forwarding. Deprecated alias to collections.abc.Callable; prefer that spelling in modern code.
Formal Syntax & Structure
python syntaxpython
typing.Callable[[Arg1, Arg2], Return]Return Value
type expression
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import Callable
def apply(fn: Callable[[int],str], value:int) -> str: return fn(value)def label(value:int) -> str: return f'#{value}'print(apply(label,7))