Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
I don't understand what does die_class() in the for loop do and why is it usefull?
I just don't understand what die_class() do and what function is it calling?
Steven Parker218,760 Points
The "die_class" was provided as an argument to the "Hand", and defines what kind of objects (die) will be rolled. The argument passed in will be the name of the class that defines those objects.
Each time "die_class()" is called, an object of that class is created so that it can be added to the "Hand". So, for example, if a hand is created by calling *
hands.Hand(size=5, die_class=dice.D6)" then you will get a set of 5 6-sided dice (which is typical for a Yahtzee game). Each call t "
die_class()" in that case will actually be creating a "D6" object.
Chul Kim2,341 Points
Just wondering is die_class just a random name that holds the actual class?
And the () is always used to call a certain function or class?