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.

Python Object-Oriented Python Dice Roller Giving a Hand

Where is class "list"?

Kenneth created a new file call hands.py. Inside this file, there is class Hand(list). My question is, where is the class "list" which Hand is extending? I don't think any class was created with the name list. So why was he extending a class that was never declared anywhere?

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 27,586 Points

The "list" class that Kenneth is subclassing is the native Python standard list class.

You are already familiar with square bracked notation for instantiating an empty list.

x = []

and this is equivalent to instatiating with the Python standard list class.

x = list()

The actual source code is implemented in 'C' language and is compiled to native binary for your particular platform. In case you are curious about this code. I linked the repository below.

https://svn.python.org/projects/python/trunk/Objects/listobject.c