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 trialLuca Vicini
Courses Plus Student 8,594 Pointsobjet oriented python - challenge task 2 of 3
Hello, I finally found the solution of the challenge. Nevertheless I am a bit confused by one thing. When we call the super() function, why don't we include the argument self?
Why do we call it like
super().add_item(item)
instead of
super().add_item(self, item)
I intuitively feel that since super() represents a generic parent class object it's like executable code, so the self shouldn't be there. But I am not 100% sure of it.
Any logical explanation?
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsThe add_item()
in the super().add_item()
is like any other called method: self
is never included in the call.
This is the same case as if a parent class had a method that was not overridden. You would also not use self
in calling this parent method.
Post back if you need more help. Good luck!!!