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 Advanced Objects Subclassing Built-ins

Simon Amz
Simon Amz
4,606 Points

parameter of the class


For parameters of the class, in this video you used 'str' or 'list', but without Uppercase, and we learn that all classes begin with an uppercase.

Does it mean that it's not a parent class? In this example, it looks like as a basic parameter.


2 Answers

Bob Pickles
Bob Pickles
1,363 Points

If I'm understanding you right, basically you're saying something like

class ReversedStr(str): should be ReversedStr(Str). If that is correct then your confusion comes from that the convention of having the first letter as uppercase is only for user-defined classes (like ReversedStr). All built-in classes are in fact lowercase (that's done to distinguish between a built-in and a user-defined class in your code.

To further expand on this explanation for you:

You create a class called Player You want Player to inherit from a dictionary so you define it like this class Player(dict): because dict is a built-in type Then you create a class called Mage You want Mage to inherit from Player so you define it like this class Mage(Player): because Player is a user defined type (one you made)

Does this make more sense?

Simon Amz
Simon Amz
4,606 Points

Hi Bob thanks for the response it is perfectly clear!