Python Derived Classes Missing One Required Positional Argument

914 views Asked by At
  class Item(pygame.sprite.Sprite):
    __metaclass__ = ABCMeta

    def __init__(self, pos_x, pos_y, image_pass):
        self.image = image_pass
        self.rect = self.image.get_rect()
        self.rect.x = pos_x
        self.rect.y = pos_y

    def draw(self, main_surface):
        main_surface.blit(self.image, (self.rect.x, self.rect.y))


class Torch(Item):
    def __int__(self, pos_x, pos_y):
        factor = 5
        self.battery = 100
        self.brightness = 2
        self.torch_image = resize(pygame.image.load("Torch.png"), factor)

        super(Torch, self).__init__(pos_x, pos_y, self.torch_image)

ERROR MESSAGE: TypeError: init() missing 1 required positional argument: 'image_pass'

I'm calling an object of torch: torch = Torch(90,450)

And im trying to load an image to pass to the base class... Item. Within the Torch class I have called the base class constructor and passed it the x and y given by the object definition. But whenever I try and pass "self.torch_image", it gives the error message seen above.

Resize() is not the issue as it has been tested elsewhere and works.

Thanks Alot.

1

There are 1 answers

0
mata On BEST ANSWER

You have a typo in your Torch class, it should be __init__, not __int__. Because of that, the inherited __init__ method of Item is called instead.