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.
mourad marzouk2,361 Points
Not sure why its working with the resizing in the init and not the super
So I followed the example Kenneth used in the video and put the call to size in the super() like this: super().init(width=3, height=3)
but it didn't work. When I looked online at others working through it. They got it to work by putting the width and height parameter in the init itself, like this: def init(self, width=3, height=3)
In the video right before this Kenneth creates a D6 class and put in it: class D6(Die): def init(self, value=0): self().init(sides=6, value=value)
So how come it worked when he pass the parameter in the super() and not the init it worked. Yet when I do the same it will not. Instead I have to pass the wight and height in the redefining of the init? If anyone can explain I would be great full, thank you. BTW I am putting all the underscores in front and after the init in the examples above, they are just not showing up.
class Board: def __init__(self, width, height): self.width = width self.height = height self.cells =  for y in range(self.height): for x in range(self.width): self.cells.append((x, y)) class TicTacToe(Board): def __init__(self, width, height): super().__init__(width=3, height=3)
Ernestas Petruoka1,856 Points
You don't need set arguments in TicTacToe class init method. You just simply need add self as argument.
class TicTacToe (Board): def __init__(self): super().__init__(width=3,height=3)