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 trialtaejooncho
Courses Plus Student 3,923 Pointscopied 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")
super().__init__()
for _ in range(size):
self.append(die_class())
self.sort()
class YatzyHand(Hand):
def __init__(self, *args, **kwargs):
super().__init__(size = 5, die_class = D6, *args, **kwargs)
Cory Hooyman
Python Web Development Techdegree Student 10,703 PointsI 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
taejooncho
Courses Plus Student 3,923 PointsHello 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
Treehouse Moderator 68,457 PointsGreat! Your code was correct all along! Keep up the good work!!!
Denis Chernenko
4,077 PointsI 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__
super.__init__()
TypeError: descriptor '__init__' of 'super' object needs an argument
Please help
Chris Freeman
Treehouse Moderator 68,457 PointsDenis, it might be best to start a new post and include your code.
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsCan you post the stacktrace output you get?