[Tutor] super question...

ali mangaliag rmangaliag@slu.edu.ph
Mon Jun 2 03:15:01 2003


This is a multi-part message in MIME format.

------=_NextPart_000_00DE_01C3291B.6CAC68C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

if i inherited class A in B... i can call the constructor of the base =
class using super... as shown below:

class A:
     def __init__(self):
             print "A constructor"

class B(A):
     def __init__(self):
             print "B constructor"
             super(B, self).__init__()
a =3D A()
b =3D B()

but when i tried to execute it... i got this error...

"""
    super(B, self).__init__()
TypeError: super() argument 1 must be type, not class
"""
dont know how to fix this... please help me...

thanks...


------=_NextPart_000_00DE_01C3291B.6CAC68C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>if i inherited class&nbsp;A in B... i =
can call the=20
constructor of the base class using super... as shown =
below:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>class A:<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
def=20
__init__(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
print "A constructor"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>class B(A):<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
def=20
__init__(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
print "B=20
constructor"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;=20
super(B, self).__init__()<BR>a =3D A()<BR>b =3D B()<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>but when i tried to execute it... i got =
this=20
error...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"""</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; super(B,=20
self).__init__()<BR>TypeError: super() argument 1 must be type, not=20
class</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"""</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>dont know how to fix this... please =
help=20
me...</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV></FONT></BODY></HTML>

------=_NextPart_000_00DE_01C3291B.6CAC68C0--