Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21125

Re: Is this the proper way to use a class method?

From John Salerno <johnjsal@gmail.com>
Newsgroups comp.lang.python
Subject Re: Is this the proper way to use a class method?
Date 2012-03-01 23:16 -0800
Organization http://groups.google.com
Message-ID <21646224.4.1330672614560.JavaMail.geo-discussion-forums@ynt13> (permalink)
References <4136337.363.1330668021961.JavaMail.geo-discussion-forums@ynjd19> <mailman.339.1330669514.3037.python-list@python.org>

Show all headers | View raw


> 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?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is this the proper way to use a class method? John Salerno <johnjsal@gmail.com> - 2012-03-01 22:00 -0800
  Re: Is this the proper way to use a class method? Chris Rebert <clp2@rebertia.com> - 2012-03-01 22:25 -0800
    Re: Is this the proper way to use a class method? John Salerno <johnjsal@gmail.com> - 2012-03-01 23:16 -0800
      Re: Is this the proper way to use a class method? Ian Kelly <ian.g.kelly@gmail.com> - 2012-03-02 01:04 -0700
      Re: Is this the proper way to use a class method? Chris Rebert <clp2@rebertia.com> - 2012-03-02 00:08 -0800
        Re: Is this the proper way to use a class method? John Salerno <johnjsal@gmail.com> - 2012-03-02 10:51 -0800
        Re: Is this the proper way to use a class method? John Salerno <johnjsal@gmail.com> - 2012-03-02 10:51 -0800
    Re: Is this the proper way to use a class method? John Salerno <johnjsal@gmail.com> - 2012-03-01 23:16 -0800

csiph-web