pychecker error

This is the place for queries that don't fit in any of the other categories.

pychecker error

Postby manojg » Tue Jul 09, 2013 6:46 pm

Hi,

I am using python 2.6.4 and ipython 0.10.2. I have a simple base class and another subclass inherited from the base class. Although it gives right output, pychecker gives me this error:
Code: Select all
particle2D.py:28: Overridden method (setPos) doesn't match signature in class (<class 'particle2D.particle2D'>)


The code is given below:
Code: Select all
#!/usr/bin/ipython

class particle2D(object):
        """ 2D particle base class """
        def __init__(self, xx, yy, rr, ww):
                self.x = xx
                self.y = yy
                self.r = rr
                self.w = ww

        def setPos(self, xx, yy, rr, ww):
                self.x = xx
                self.y = yy
                self.r = rr
                self.w = ww

        def getPos(self):
                self.pos = [self.x, self.y, self.r, self.w]
                return self.pos
#---------------------------------------------------------------

class particle3D(particle2D):
        """ 3D particle class inherited from particle2D """
        def __init__(self, xx, yy, zz, rr, ww):
                super(particle3D, self).__init__(xx, yy, rr, ww)
                self.z = zz

        def setPos(self, xx, yy, zz, rr, ww):
                super(particle3D, self).setPos(self, xx, yy, rr, ww)
                self.z = zz

        def getPos(self):
                self.pos = [self.x, self.y, self.z, self.r, self.w]
                return self.pos
#---------------------------------------------------------------


Any idea will be appreciated.
Thanks.
manojg
 
Posts: 13
Joined: Tue Jul 09, 2013 6:40 pm

Re: pychecker error

Postby ochichinyezaboombwa » Tue Jul 09, 2013 9:38 pm

self is not required, it's implied. Use
Code: Select all
super(particle3D, self).setPos(xx, yy, rr, ww)


PS: Also, you have the same code in init and setPos: why?!?
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: pychecker error

Postby micseydel » Wed Jul 10, 2013 1:38 am

Because he doesn't know he can do
Code: Select all
        def __init__(self, xx, yy, rr, ww):
            self.setPos(**locals())
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1262
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: W3C [Linkcheck] and 5 guests