Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Using the Python kwargs Variable in Function Definitions

Zarata on April 15, 2020

The examples show how one might access the keys OR the values of the dictionary, but that leaves the question of why one would pass a dictionary as a whole rather than just keys or values. Have you a good example of how having each map item as a whole is uniquely useful within a function?

Mike K on June 7, 2020

@Zarata - Keyword arguments are dictionaries because you associate a name with a value. Here is the description of keyword arguments from the official documentation - keyword argument: an argument preceded by an identifier (e.g. name=) in a function call or passed as a value in a dictionary preceded by *.*

You will have to pass the whole dictionary to the function because keys and values alone are technically meaningless unless used together.

Become a Member to join the conversation.