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 trialKohei Ashida
4,882 PointsWhy don't you need "self" parameter?
Why don't you need "self" parameter when you call super() like super.init(self, name, **kwargs) instead of super().init(name, **kwargs)?
2 Answers
Steven Parker
231,275 PointsThey system adds the "self" parameter when the call is processed, it's not passed as an explicit argument. This is unrelated to the use of "super", and happens on any class method.
Kohei Ashida
4,882 PointsThanks for quick response as always, Steven! So you're saying that the "self" parameter in the method is systematically added when the method itself is written in another method of a class?
Steven Parker
231,275 PointsSteven Parker
231,275 PointsThe system's insertion of the "self" argument happens anytime you make a method call, whether it is done inside the same (or another) class or just in the outer code.
Kohei Ashida
4,882 PointsKohei Ashida
4,882 PointsThanks Steven! Now I understood that the system's insertion happens anytime I make a method call but why don't you need "self" parameter when you define a method in another method like below.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsThat second line is not a definition, it is calling the other method. The call is where you don't supply a "self" because the system will add it for you.
Kohei Ashida
4,882 PointsKohei Ashida
4,882 PointsThank you for your explanation! Now I got it that I misunderstood the second line is the same thing as the "def" line.