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 Python Basics (2015) Python for Beginners The Python Shell

What is a class in Python?

At 7:08, Kenneth says "String belongs to a class or an object that's named S-T-R."

https://en.wikibooks.org/wiki/Python_Programming/Classes#str

  • "Classes are a way of aggregating similar data and functions. A class is basically a scope inside which various code (especially function definitions) is executed."

It appears that the term 'class' is delineated in multiple scopes. One being it aggregates similar types of data. So is class and data type used interchangeably? The class 'str' signifies all values that are a set of character strings?

With regards to "A class is basically a scope inside which various code (especially function definitions) is executed."

So in some instance if someone wanted to combine a set of functions to perform a unique computation the class would identify those functions whenever it was called?

2 Answers

The data type of string is an object. For the basics class that means that you can call functions like .lower() on your strings and do cool things to them (in that case make it all lowercase). In a later course they will show you how to create classes/objects of your own and then you will have more detailed answers about what a class/object is. For now, it just means you can call functions on the strings.

I am unclear as to what an object is. When you say the data type of string is an object do you mean that any set of characters enclosed within a set of parenthesis is an object?

For example when I have:

computer = "hp"

"hp" is considered an object?

Benjamin,

Yes you are correct, "hp" is considered a string object.