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

I don't understand why does Monster.hit_points can sign to value, why does a class can give a value to him?

\\class Monster:

      color = 'yellow'

      hit_points = 1 

      weapon = 'sword'

Monster.hit_points = 4 ### \\

I don't understand why does you could do this. Because the people always say class is blueprint, and you always work on the object, but in this situation, the wired things happened which could be signed a value. Which is like I could use a paper and draw a building, after that I could sell it, just like normal building. Can anybody clear that for me, because the class has so many variable situations like this.

2 Answers

A class IS similar to a blueprint. You can make many objects all based off of the same class, but instead of retyping the color, hit_points, and weapon each time, you can just type out the object's property that is different from the property used in the class. Classes are used for brevity.

But for my questions is why does you could give class-self values. I understand you could give instance to a new property, but I think if class is a blueprint, the coder who design python class should not allow people to original class after you have created class. You should only change instance.