In this step-by-step tutorial, you’ll learn how to use args and kwargs in Python to add more flexibility to your functions. You’ll also take a closer look at the single and double-asterisk unpacking operators, which you can use to unpack any iterable object in Python.
Sometimes, when you look at a function definition in Python, you might see that it takes two strange arguments: ***args**
and ****kwargs**
. If you’ve ever wondered what these peculiar variables are, or why your IDE defines them in main()
, then this article is for you. You’ll learn how to use args and kwargs in Python to add more flexibility to your functions.
By the end of the article, you’ll know:
*args
and **kwargs
actually mean*args
and **kwargs
in function definitions*
) to unpack iterables**
) to unpack dictionaries#python #programming #developer