**kwargs
**kwargs is Python function-parameter syntax that collects arbitrary keyword arguments into a dictionary keyed by their names.
Python How-To
kwargs is the conventional parameter name for a dictionary that collects variable-length keyword arguments passed to a Python function.
- How it is used
- Collects a variable number of keyword arguments in a function, including optional settings and decorator-wrapper calls.
- How deep it goes
- Explains dictionary packing, parameter placement, iteration, defaults, and the clarity trade-off; does not descend into interpreter internals.
- Examples
- Uses a grade-report function, optional calculation settings, and a decorator that fails when its wrapper accepts no arguments.
- What you can do after
- Build it from scratch in Python functions to collect optional keywords, read defaults, and write wrappers compatible with differing calling signatures.
Python Workout: 50 ten-minute exercises
Python function-parameter syntax that collects an arbitrary number of keyword arguments into a dictionary.
- How it is used
- Collects flexible named options for formatted output, dynamic dispatch, and constrained object queries.
- How deep it goes
- Explains dictionary creation and iteration through complete XML code, then applies the pattern to dispatch and filtering.
- Examples
- Uses XML-like tag generation, menu dispatch, and an Animal-query method accepting color and legs.
- What you can do after
- Build flexible Python functions that format, inspect, or dispatch arbitrary named arguments.
Read how Python Workout: 50 ten-minute exercises explains **kwargs →
The Well-Grounded Python Developer: How the pros use Python and Flask
A variadic keyword parameter is a function parameter that collects an arbitrary number of keyword arguments into a mapping.
- How it is used
- Uses a flexible keyword collection when functions need to receive, inspect, or forward varying named data.
- How deep it goes
- Defines the collection and lookup behavior, then cautions that undocumented keys and intentional forwarding require care.
- Examples
- Uses full_name to inspect fname, mname, and lname while contrasting flexible collection with explicitly named parameters.
- What you can do after
- Apply it via Python function definitions to collect, inspect, ignore, or forward arbitrary keyword arguments deliberately.
Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains **kwargs →
Related concepts
- Mapkind of · A map is an associative data structure that stores key-value pairs and supports retrieving values by key.
- named argumentuses · A named argument is a function or command argument supplied by explicitly associating its value with a parameter name rather than relying solely on position.
- dispatch tableused by · A dispatch table is a mapping from operation or case identifiers to callable implementations selected and invoked at runtime.
- variadic argumentskind of · A variadic function or parameter accepts a variable number of arguments, often collecting the supplied values into a sequence of a specified type.
- parameterkind of · A model parameter is a numerical value, such as a weight or bias, that is learned or set to determine how a model computes outputs.
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.


