Re: having a function called after the constructor/__init__ is done

2009-03-16 Thread Michael Spencer
thomas.han...@gmail.com wrote: ... So any ideas on how to get a function called on an object just after __init__ is done executing? -- http://mail.python.org/mailman/listinfo/python-list Yes, you *can* use metaclasses - you need to override the type.__call__ method, which is what normally ca

Re: having a function called after the constructor/__init__ is done

2009-03-16 Thread Steven D'Aprano
On Mon, 16 Mar 2009 20:11:18 -0700, thomas.han...@gmail.com wrote: > Hi all, > > We've been breaking our heads over a good way of accomplishing an > "on_load" event in our multitouch GUI frameowork PyMT. We think we'd > like to trigger an "on_load" event after a class is fully instantiated ... >

Re: having a function called after the constructor/__init__ is done

2009-03-16 Thread Armin Moradi
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) s

Re: having a function called after the constructor/__init__ is done

2009-03-16 Thread alex goretoy
__del__ I use it to close a mysql connection -Alex Goretoy http://www.goretoy.com E. B. White - "Be obscure clearly." On Mon, Mar 16, 2009 at 10:11 PM, thomas.han...@gmail.com < thomas.han...@gmail.com> wrote: > Hi all, > > We've been breaking our heads over a good way of accomplishing an > "

having a function called after the constructor/__init__ is done

2009-03-16 Thread thomas.han...@gmail.com
Hi all, We've been breaking our heads over a good way of accomplishing an "on_load" event in our multitouch GUI frameowork PyMT. We think we'd like to trigger an "on_load" event after a class is fully instantiated (or just a function call for simplicity, so you dont need to worry about our specif