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

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 28,720 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