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


Groups > comp.lang.python > #21126

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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <johnjsal@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'method,': 0.05; 'argument,': 0.09; 'arguments,': 0.09; 'be:': 0.09; 'subclass': 0.09; 'subject:method': 0.09; 'to:addr:comp.lang.python': 0.09; 'two.': 0.16; 'cc:addr:python-list': 0.16; 'instance': 0.18; 'cc:no real name:2**0': 0.21; "doesn't": 0.22; 'header:In-Reply- To:1': 0.22; 'subject:use': 0.24; 'tried': 0.27; 'cc:addr:gmail.com': 0.28; 'class': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.30; 'subject:?': 0.31; 'actually': 0.31; 'does': 0.32; "isn't": 0.33; 'received:209.85.212': 0.33; 'header:User- Agent:1': 0.33; 'it?': 0.33; 'thank': 0.35; 'be.': 0.35; 'cc:2**1': 0.36; 'passed': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'using': 0.37; 'happens': 0.38; 'received:209.85': 0.38; 'getting': 0.38; 'received:209': 0.39; 'your': 0.61; 'subject:this': 0.74; 'contrast,': 0.84; 'received:209.85.212.56': 0.91; 'received:mail- vw0-f56.google.com': 0.91
Received-SPF pass (google.com: domain of johnjsal@gmail.com designates 10.236.201.161 as permitted sender) client-ip=10.236.201.161;
Authentication-Results mr.google.com; spf=pass (google.com: domain of johnjsal@gmail.com designates 10.236.201.161 as permitted sender) smtp.mail=johnjsal@gmail.com
Newsgroups comp.lang.python
Date Thu, 1 Mar 2012 23:16:54 -0800 (PST)
In-Reply-To <mailman.339.1330669514.3037.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=76.30.237.113; posting-account=Wdz3OgoAAACumWTKfPjpOEJc3twpMp_1
References <4136337.363.1330668021961.JavaMail.geo-discussion-forums@ynjd19> <mailman.339.1330669514.3037.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
MIME-Version 1.0
Subject Re: Is this the proper way to use a class method?
From John Salerno <johnjsal@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org, John Salerno <johnjsal@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.342.1330672617.3037.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330672617 news.xs4all.nl 6894 [2001:888:2000:d::a6]:55497
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21126

Show key headers only | 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 | 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