It’s Day 20. Today we finish off with a few more options for the types of arguments you can have in a function.
Introducing args and kwargs
00:00
For many people learning Python, one of the topics that seems a bit strange and bizarre and difficult at first is *args
and **kwargs
.
00:10
You will sometimes see in function definitions, *args
or **kwargs
, or often you would see both. Now, this topic is not as complex as it sounds, and we’re going to focus on it today.
00:23
It’s a way of making function calls even more flexible. Now, there are some people who think that *args
and **kwargs
can be abused, and in fact, they shouldn’t be used too much.
00:36
However, you will see them in Python code, so you need to know about them. And also there are instances, and we’ll see some next week, where you do need to use *args
and **kwargs
.
00:46 So it’s an important topic to understand for those two reasons: you see them often, therefore, you need to understand them, and there are instances where you might need to use them as well.
00:55 We’ll also today finish off the topic about what types of arguments can we have by looking at, you’ve already seen positional arguments and keyword arguments, but sometimes you can force an argument to be positional only, and that’s the only choice you have, or keyword only.
01:12 So we’ll finish today by looking at positional only and keyword only arguments, and then that will give you all of the information. You’ll know everything about all the types of arguments you can have in a Python function.
You must own this product to join the conversation.