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 trialhenry jefferson
2,136 PointsIs this an instance?
In making the class Game() we make a list called monsters , which looks like this: self.monsters = [ Troll(), Goblin(), Dragon() ] . Later we then go on to .pop() one out of the list and assign it to self.monster. The question really is, can a list be an instance? Is Monsters an instance or is it just a list and the real instance when we .pop one of the list out and assign it to self.monster?
Many Thanks
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsThe short answer is an instance is an instantiation of an object. Instances as independent of each other.
So Troll
is the class, Troll()
returns an instance of Troll
.
self.monsters
Is an instance of a list
with three elements, each of which are instances of their respective monster classes.
Post back if you need more clarification.