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 Giving a Hand

need help with understanding super() use.

So I need help understanding a couple of things:

  1. I understand that a class without a specified parent class always has python's parent class of 'object'. However, why do we need to use super. Thought this was so taht we could borrow a paren'ts initialization method, but here we aren't even using arguments (in the first part of the video).

  2. I thought the parenthesis for a subclass was used to specify the name of a parent class, but here we use 'list'. I'm not sure I understand how we are allowed to do this, and how python differentiates between a class parent name and a type argument.

Thanks!

1 Answer

Ryan Cross
Ryan Cross
5,742 Points

1 One of the important things children get from super().init() are the parents methods. List has append , extend etc. Without super()init() you would either not have any of those or have to design/build them if you needed them.

2 List is a class. its true its a built in class like string or tuple but none the less it is a class. It has object as a parent and it can have children. Here we make a class based on list. list is a parent to Hand.