Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Shaun Barbour
Courses Plus Student 1,907 Pointsparameters, positional arguments, arguments with default values, keyword arguments, *args, **kwargs. please help!
for the love of god, would someone please make some sense of all this? all these words keep floating around, sometimes as synonyms. everyone seems to use them differently, especially parameters and arguments. i've watched the video several times, and i've read dozens of articles on this. i'm still scratching my head.
can someone define the terms? the semantics?
...in the context of defining the function vs. calling the function.
suggestion: there needs to be a separate python video tutorial just on this.
thanks!
1 Answer
Jeff Muday
Treehouse Moderator 28,731 PointsI agree, it can be confusing at first, but it demonstrates the flexibility of Python functional programming. I can guarantee you will need to use it at some point in your Python journey!
Basically...
*args allows you to specify that a function can take in a variable number of arguments
**kwargs (stands for keyword arguments) allows you to send in a variable number of named parameters (like a dictionary)
I could rehash this for you, but, better yet, take a look at this well-written blog article from one of my favorite hosting providers-- Digital Ocean:
https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3
If you worked your way through the article and understood it, great! If not, keep practicing until you get it right-- you will need it at some point.
Shaun Barbour
Courses Plus Student 1,907 PointsShaun Barbour
Courses Plus Student 1,907 PointsThanks so much, Jeff! Really appreciate the response.