Hey list,

I think I got this right, and it seems to work, but I just feel like there
is probably a better way to override a method in IP. Some time spent
googling doesn't bring anything up except for IP/C# code examples containing
the override keyword. For example, I want to override the Form class' OnLoad
method, so I wrote a decorator to do so.

class frm(Form):
    def __init__(self):
            Form.__init__(self)

    def override(method):
        def inner(*args):
            base = super(Form, args[0]) #args[0] is frm instance
            base_method = getattr(base.__thisclass__, method.__name__)
            method(*args) #call our method first
            return base_method(*args)
        return inner

    @override
    def OnLoad(self, evt_args):
            print evt_args

It doesn't do anything snazzy - just prints out the EventArgs, then calls
the base class Form.OnLoad.

Any thoughts?

Brian
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to