Is this the proper way to use a class method?

John Salerno johnjsal at gmail.com
Fri Mar 2 02:16:54 EST 2012


> That's just a coincidence. Your supercall is ought to be: super().move()
> In contrast, super().move(self) calls the superclass instance method
> `move` with 2 arguments, both `self`, which just happens to work given
> your move() method, inside which `cls` isn't actually a class like it
> ought to be.

Thank you! This is the whole reason I tried using a class method in the first place. I was getting an error that said my move method only takes one argument, but I was passing in two.

But if I make the super call as super().move(), how does that work? The move method in the superclass takes an argument, and if I just do super().move(), isn't it the subclass that's getting passed to it? How does the superclass move method know what 'self' is if it doesn't get passed to it as I did originally?



More information about the Python-list mailing list