Rebinding __setattr__

alex23 wuwei23 at gmail.com
Mon Sep 15 21:44:29 EDT 2008


On Sep 16, 7:12 am, "Jan Schilleman" <jan.schille... at xs4all.nl> wrote:
> That still would require changing the source of the library ... And i'm not
> sure if it would have side effects.

I'm not on a Windows box so can't test this atm, but perhaps you could
make a proxy object?

class DispatchBaseProxy(object):
    def __init__(self):
        self.base = DispatchBaseClass()
    def __setattr__(self, attr, value):
        "insert extra functionality here"
        setattr(self.base, attr, value)
    def __getattr__(self, attr):
        getattr(self.base, attr)
    ...etc...




More information about the Python-list mailing list