<div>Here's how you do inheritance:<br clear="all"></div><div><br></div><div><font face="courier new,monospace">C:\>python<br>Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on<br>win32<br>
Type "help", "copyright", "credits" or "license" for more information.<br>>>> class BaseClass(object):<br>... def __init__(self, a, b, c, d):<br>... self.a = a<br>
... self.b = b<br>... self.c = c<br>... self.d = d<br>...<br>>>> class NewClass(BaseClass):<br>... def __init__(self, a, b, c, d, new):<br>... super(NewClass, self).__init__(a, b, c, d)<br>
... self.new = new<br>...<br>>>> A = BaseClass(1,2,3,4)<br>>>> print A.a, A.b, A.c, A.d<br>1 2 3 4<br>>>> B = NewClass(1,2,3,4,5)<br>>>> print B.a, B.b, B.c, B.d, B.new<br>
1 2 3 4 5<br>
>>></font><br></div><div><br></div>~/santa<br>
<br><br><div class="gmail_quote">On Tue, Mar 8, 2011 at 5:00 PM, Martin De Kauwe <span dir="ltr"><<a href="mailto:mdekauwe@gmail.com">mdekauwe@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Mar 9, 11:50 am, "Rhodri James" <<a href="mailto:rho...@wildebst.demon.co.uk">rho...@wildebst.demon.co.uk</a>><br>
wrote:<br>
> On Wed, 09 Mar 2011 00:29:18 -0000, Martin De Kauwe <<a href="mailto:mdeka...@gmail.com">mdeka...@gmail.com</a>> <br>
<div class="im">> wrote:<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> > On Mar 9, 10:20 am, Ethan Furman <<a href="mailto:et...@stoneleaf.us">et...@stoneleaf.us</a>> wrote:<br>
> [snip]<br>
> >> Just make sure and call the parent's constructor, either with<br>
><br>
> >> class NewClass(BaseClass):<br>
> >> def __init__(self, ....):<br>
> >> BaseClass.__init__(self, other_params)<br>
><br>
> >> or<br>
><br>
> >> class NewClass(BaseClass):<br>
> >> def __init__(self, ....):<br>
> >> super(NewClass, self).__init__(....)<br>
><br>
> >> ~Ethan~<br>
><br>
> > Hi thanks, but I think I am implementing it wrong then?<br>
><br>
> > BaseClass has 4 attributes and when I tried what you said<br>
><br>
> > class NewClass(BaseClass):<br>
> > def __init__(self):<br>
> > super(NewClass, self).__init__(new_thing)<br>
><br>
> > I get the error<br>
><br>
> > TypeError: __init__() takes exactly 1 argument (6 given)<br>
><br>
> Please give us either the rest of the code or the rest of the<br>
> traceback, or preferably both. Without one or the other we have<br>
> little hope of guessing what you've typed.<br>
><br>
> --<br>
> Rhodri James *-* Wildebeest Herder to the Masses<br>
<br>
</div>OK<br>
<br>
class BaseClass(object):<br>
<br>
def __init__(self, a, b, c, d):<br>
self.a = a<br>
self.b = b<br>
self.c = c<br>
self.d = d<br>
<div class="im"><br>
<br>
class NewClass(BaseClass):<br>
def __init__(self):<br>
</div> super(NewClass, self).__init__(new)<br>
self.new = new<br>
print self.new<br>
<br>
class PreviousClass:<br>
def __init__(self, a, b, c, d, new):<br>
self.a = a<br>
self.b = b<br>
self.c = c<br>
self.d = d<br>
self.new = new<br>
print self.new<br>
<br>
<br>
if __name__ == "__main__":<br>
<br>
A = PreviousClass(1, 2, 3, 4, 5)<br>
B = NewClass(1, 2, 3, 4, 5)<br>
<br>
$ python test.py<br>
Traceback (most recent call last):<br>
File "model_data.py", line 29, in <module><br>
B = NewClass(1, 2, 3, 4, 5)<br>
<div class="im">TypeError: __init__() takes exactly 1 argument (6 given)<br>
<br>
<br>
<br>
</div>So NewClass is my attempt to implement what I was shown and<br>
PreviousClass was how I was originally solving the issue, i.e. I<br>
wouldn't inherit the BaseClass.<br>
<br>
thanks<br>
<div><div class="h5">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>