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()
        def fromfile(self):
                pass
        def getName(self):
                pass

class typeA(baseClass):
        def __init__(self):
                self.name='A'
                print 'typeA init'
        def fromfile(self):
                print 'typeA fromfile'
        def getName(self):
                print self.name

class typeB(baseClass):
        def __init__(self):
                self.name='B'
                print 'typeB init'
        def fromfile(self):
                print 'typeB fromfile'
        def getName(self):
                print self.name

a = baseClass('A')
a.fromfile()
a.getName()

b = baseClass('B')
b.fromfile()
b.getName()

log:
typeA init
typeB init

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to