trouble understanding inheritance...

KraftDiner bobrien18 at yahoo.com
Wed Aug 16 14:59:27 EDT 2006


Fredrik Lundh wrote:
> KraftDiner wrote:
>
> > This is not working the way I think it should....
> > it would appear that fromfile and getName are calling the baseClass
> > methods which are
> > simple passes.... What have I done wrong?
> >
> > class baseClass:
> > 	def __init__(self, type):
> > 		if type == 'A':
> > 			self = typeA()
> > 		else:
> > 			self = typeB()
>
> __init__ is not a constructor, and assigning to self doesn't change the
> type of the constructed object.
>
> looks like you need to get a better tutorial.
>
> </F>

Well how does one select which class baseClass really is when you
contruct the object?
What am I missing?

a = typeA()
b = typeB()
c = baseClass(a)




More information about the Python-list mailing list