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 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,423 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,423 Points

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