Skip to main content

2 docs tagged with "kwargs"

View all tags

*args and **kwargs: Accepting a Variable Number of Arguments

We've learned how to define functions with a fixed number of positional and keyword arguments. But what if you want to create a function that can accept any number of arguments? For example, a function that can sum two numbers, or five, or a hundred. This is where args and *kwargs come in, providing the ultimate flexibility for your function definitions.

Decorators (Part 2): Decorators with Arguments

In our last article, we learned that a decorator is a function that wraps another function to add new behavior. However, our first decorator was simple: it only worked on functions that took no arguments.