you can also try to wrap your function. Something on the line of
def wrapper(func, bool_arg):
def inner(*args, **kwargs):
kwargs['bool_arg']=bool_arg
return func(*args, **kwargs)
return inner
and
class C():
def fun(...):
...
c = C()
c.fun = wrapper(fun, False)
should work
Edit
If you want to change the default for the class and not for a particular instance you can create a derived class and redefine fun
wrapping the method of C
. Something on the line (I don't have now the time to test it):
class D(C):
def fun(self, *args, **kwargs):
f = wrapper(C.f, False)
return f(*args, **kwargs)
Then about the suggestion of @Ber, you can define def wrapper(func, **wrapkwargs)
and then instead of kwargs['bool_arg']=bool_arg
do
for i in wrapkwargs.iteritems(): #wrapkwargs is a dictionary
kwargs[i[0]] = i[1]