[Tutor] calling the constructor of an inherited class
ali mangaliag
rmangaliag@slu.edu.ph
Fri May 30 03:44:02 2003
> I believe you meant 'class y(x):' above. Anyway, you call the parent's
> __init__ just like any other function:
thanks for the correction... got it... thanks again..
> class A:
> def __init__(self,name):
> self.name=name
>
> class B(A):
> def __init__(self, name, address): ## added address parameter
> A.__init__(self,name)
> self.address=address
>
> me = B('Don','12345 Main St')
>
> print me.name
> print me.address
>
> >>> Don
> >>> 12345 Main St
>
> HTH,
> Don
>
>
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor