Discussion on: Python: What are *args and **kwargs?

adamlombard profile image
Adam Lombard Author

In our simple example, there isn't much of a difference.

In a real-world example, the *args and *kwargs syntax give us more options in how we accept data into our function.

The decision is largely one between forcing the use of structured data, and not needing to know the structure in advance. In your example, we must always pass in a list or dictionary, even if we are only passing in a single hobby. (This approach is not necessarily bad -- it may, in fact, be the right solution.) If, instead, we allow variable-length arguments -- by using the *args or *kwargs syntax -- then we do not need to structure the data in advance.

A more in-depth discussion related to your question can be found here.