Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jean Beltre
1,181 PointsWhy do we unpack a dictionary, if there isn't a dictionary specified (Self, **kwargs) ?
Why do we unpack a dictionary, if there isn't a dictionary specified (Self, **kwargs) ?
def init (self, **kwargs): # during initialization the first parameter is within this instance, unpack dictionary ??
why are we unpacking the dictionary as a parameter to the function.
1 Answer

Kenneth Love
Treehouse Guest TeacherWe're actually packing the dictionary here. The **
allows us to take any number of keyword arguments and turns them into a dict when we get into the method itself.
Kevin Faust
15,353 PointsKevin Faust
15,353 PointsThis is a sidecomment but you never pass in a dictionary when creating an object and this leads to the mass confusion. Why are we packing a dictionary, why are we using setattr, etc. when we are not doing it and not once have you shown it either. It would have been better if an example was shown