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.
need help with understanding super() use.
So I need help understanding a couple of things:
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).
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.
Ryan Cross5,741 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.