June 22nd, 2005, 03:21 AM
Super class methods
Hey Im quite new to python. Ive created a derived class, and I have overridden one of the super class' methods, but I also want to call the super class' method (kind of adding to it).
I think thats working. The super class' method calls another method which i've overridden normally. It returns a list. But I get an error:
ValueError: Too many values to unpack
what does that mean?
June 22nd, 2005, 03:34 AM
Well, you get this error if you try something like this:
a,b = [1,2,3] # -> error
a,b,c = [1,2,3] # -> no error ;)
Comments on this post
June 22nd, 2005, 03:59 AM
yeah, i realised that the superclass method is calling one of its other methods.
The superclass' method does stuff and calls another one of its methods (that is must be overridden by a subclass). So I i've overridden it in my subclass, but when I call the superclass' method, it does the work and then calls its other method (which just returns an error string) instead of calling my overridden method. arghh!
When I hadn't overridden meth1, and just used the inherited meth1 it worked fine and called the overridden meth2(in SubClass), but now that I've overridden meth1 (and called its super version) it calls SuperClass' meth2 instead of SubClass'.
[a,b] = meth2(a,b)
return "Unimplemented method meth2"
obj = SubClass(...)
Is there a way of getting meth1, to call meth2 in the subclass. Am I going wrong somewhere? I'm not really able to change SuperClass.meth1
June 22nd, 2005, 04:35 AM
made a very stupid mistake in my code.