having a function called after the constructor/__init__ is done

Armin Moradi feng.shaun at gmail.com
Mon Mar 16 23:45:16 EDT 2009


class MyClass(object):
   def __init__(self, really_init=True):
       self.a = 3
       self.b = 4
       # other initialization
       if really_init: on_load()

   def on_load(self):
       print 'hello!'

class B(MyClass):
    def __init__(self):
        super(B, self).__init__(False)
        self.c = 4
        print "B initialized"
       MyClass.on_load()

    def on_load(self):
        print 'hello!'


Would this work?

(posted it again to include the python-list in To:)

-- 
Armin Moradi



More information about the Python-list mailing list