KraftDiner wrote: > 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)
a = typeA() b = typeB() You're done. Stop there. You can't "select which class baseClass really is"-- it really is baseClass. You "select" which class your object is by choosing which class to use to construct the object. HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list