Python *args **kwargs
- Views
- 351K
- Likes
- 18.8K
- Comments
- 172 comments
- Shares
- 514
- Saves
- 4.8K
Show more details Subtitles, video quality and playlist
Transcript
Why do Python developers write star args and double star quargs? Look at this code def function star args double star quargs be honest, how many times have you seen this and just copied it without understanding it? Why the stars? Why these weird names, and what do they actually do? Here's the interesting part star args lets a function accept many values without knowing exactly how many you will pass. For example, 1 value, 3 values, 10 values, Python collects them all into one place. And Double Star Quarks does something similar, but for named values like name, age, email. Instead of collecting simple values, it collects labeled values. So the easiest way to think about them is this star Args collects extra values, double star quargs collects extra named values. And once you understand that, a lot of Python code suddenly becomes much less scary. Now I want to know did Args and cargs confuse you when you first saw them? Write your answer in the comments.