[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 A in B... i =
can call the=20
constructor of the base class using super... as shown =
below:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>class A:<BR> =
def=20
__init__(self):<BR> =
=20
print "A constructor"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>class B(A):<BR> =
def=20
__init__(self):<BR> =
=20
print "B=20
constructor"<BR> &nb=
sp; =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> </DIV>
<DIV><FONT face=3DArial size=3D2>"""</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> 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> </DIV>
<DIV><FONT face=3DArial size=3D2>thanks...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </DIV></FONT></BODY></HTML>
------=_NextPart_000_00DE_01C3291B.6CAC68C0--