default argument in method

DevPlayer devplayer at gmail.com
Thu Dec 30 14:26:50 EST 2010


There's some_object.some_method.func_defaults and
some_function.func_defaults both are a settable attribute. How to set
the methods func_defaults? You'd have to have code in
_getattribute__(yourmethod) if not __getattr__(yourmethod)

def __getattribute__(self, attr):
    if attr == self.my_method:
        # something like this, but i'm probably a little off
        # you might need to use super or something to prevent
recursive __getattribute__ calls here
        self.my_method.func_defaults = self.foo




More information about the Python-list mailing list