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.

Python Object-Oriented Python Dice Roller Giving a Hand

copied the code exactly from the video, but when I try Python runs NameError.

I copied the code from the video to WorkSpace, and when I try to do yh = YatzyHand() in the console python raise NameError saying the name 'args' is not defined...

I even downloaded the zip file to get the code from this video only to find that python is raising NameError again.

So, my question is what is wrong?? Why is python doing this?

m hands.py code was this

from dice import D6

class Hand(list):
    def __init__(self, size = 0, die_class = None, *args, **kwargs):
        if not die_class:
            raise ValueError("You must provide a die class")

        for _ in range(size):

class YatzyHand(Hand):
    def __init__(self, *args, **kwargs):
        super().__init__(size = 5, die_class = D6, *args, **kwargs)
Cory Hooyman
Cory Hooyman
Python Web Development Techdegree Student 10,703 Points

I am having the same issue mentioned above, as I am receiving a name error - @taejooncho, can you confirm that nothing else was changed prior to re-running the YatzyHand class?

2 Answers

Hello Mr.Freeman,

Thank you for your time and interest. I did not know what you meant by stacktrace output, so I just tried to do yh = YatzyHand() again and copy the entire NameError python was raising and post here, and I don't know if it is because I had to reload my workspace due to inactivity, but now it works!?

I did not change a thing, so...

Either way Thank you!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,064 Points

Great! Your code was correct all along! Keep up the good work!!!

I have same problem, trace is the following:

Traceback (most recent call last):

  File "<ipython-input-25-8ce6271ae554>", line 3, in <module>
    import game_kosti, game_kosti2

  File "C:/python\game_kosti2.py", line 20, in <module>
    hand = game_kosti2.Hand(size=5, die_class = game_kosti.D6)

  File "C:/python\game_kosti2.py", line 16, in __init__

TypeError: descriptor '__init__' of 'super' object needs an argument

Please help

Chris Freeman
Chris Freeman
Treehouse Moderator 68,064 Points

Denis, it might be best to start a new post and include your code.