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 trialThan Win Hline
1,679 Pointsself._by_value(1)
I don't understand how can we use self in self.by_value(1). I get self is confusing most of the times. can anyone please give a clear understanding of using 'self'? class YatzyHand(Hand): def __init(self,args,*kwargs): super().init_(size=5,die_class=D6,args,*kwargs) @property def ones(self): return self._by_value(1)
1 Answer
Steven Parker
231,275 PointsThe "self" reference is just a convenient way to refer to a specific class instance from within the class code. When writing the class, the actual name of the instance(s) is not known, and you wouldn't want to be dependent on a particular name anyway.