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 trial

Python Object-Oriented Python Dice Roller Project Breakdown

Super() Arguments

I know this was a topic covered earlier, but being able to practice highlighted some lack of understanding.

What is the difference between the arguments placed in the init() method vs the super().init() method?

And what is the purpose in assigning value = 0 in the init() method, and then setting value = value within the super().init() method? Isn't that redundant?

class D6(Die):
    def __init__(self, value = 0):
        super().__init__(sides = 6, value = value)

1 Answer

Steven Parker
Steven Parker
229,670 Points

The names on the "def" line are parameters (incoming) of the current class Those in the call to the "super" method are arguments being passed to the parent method.

The "value = 0" in the "def" line defines an optional positional parameter. If one is not passed in, it will get the value of 0. But the "value = value" in the call passes a keyword argument (kwarg) to the parent method.