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:

  • What *args and **kwargs actually mean
  • How to use *args and **kwargs in function definitions
  • How to use a single asterisk (*) to unpack iterables
  • How to use two asterisks (**) to unpack dictionaries

#python #programming #developer

How to use Args and Kwargs in Python
1.75 GEEK