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 trialBasel Kanaan
4,458 Pointswhats the different between **kwargs and *args is the first one only used for dictionaries?
and can we use the second one dictionaries also?
1 Answer
Steven Parker
231,236 PointsThe conventional name "kwargs" stands for "keyword arguments" which are key/value pairs. The double-asterisk packing operator is specifically for converting these pairs into a dictionary.
On the other hand "args" are just simple arguments, and the single "splat" converts them into a list.
The names themselves are simply conventions, but mixing them up could be very confusing for another Python developer!
Nicholas Johnson
12,945 PointsNicholas Johnson
12,945 Points@Steven Parker, I thought the single asterisk converted them into a tuple, not a list?