[Python] What is the difference between super() with arguments and without arguments?

Discussão em 'Python' iniciado por Stack, Janeiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I encountered a code which uses the super() method in 2 different ways, and I can't understand what's the difference in the logic.

    I'm learning right now the pygame module and I got a task to create a class of a Ball which inherits from Sprite which is a class from the pygame module (if I'm not mistaken).

    I encountered this code:

    import pygame

    class Ball(pygame.sprite.Sprite):

    def __init__(self, x, y):
    super(Ball, self).__init__()


    And I can't understand the difference from:

    import pygame

    class Ball(pygame.sprite.Sprite):

    def __init__(self, x, y):
    super().__init__()


    (Argument of super() method)

    What is the difference between those code blocks in their logic? Why do I need to pass to super() method arguments? What are those arguments required to be?

    Continue reading...

Compartilhe esta Página