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.

Python

Nicholas Gaerlan
Nicholas Gaerlan
9,501 Points

Why do you need to explicitly provide an argument when **kwargs takes any key, value pair?

In the example for the video, why can't you still create a "Thief" with the same arguments

person = Thief("Bob", sneaky=False, hair_style = "sad mullet")

without overriding the parent class __init__ method? As long as a string for a name variable is declared first, then as long as every following element is a "key, value" pair or "var = [data-type]", wouldn't your Thief end up inheriting that attribute?

So if in this case, without overriding the parent method with the "super()" call, if I just initialized a Theif with the arguments ("Bob", sneaky = False) then I understand this to happen:

  1. A Theif is created inheriting all the Parent methods and attributes
  2. Since the parent accepts all key, value pairs and creates attributes from them, then the Thief should have a sneaky = False attribute because I used that argument.

I see a potential conflict in that the sub-class of Thief sets it's attribute to "True" by default, so is that it? I guess I'd like to know the order or sequence of events so that I understand exactly when things are created and overridden.