I've tried doing this in Python 2.6, and it does "work":
>>> def f(i='I'): return i
...
>>> f.func_defaults = (10,)
>>> f()
10
But is this officially specified behavior, or am I hitting an implementation-specific behavior?
I've tried doing this in Python 2.6, and it does "work":
>>> def f(i='I'): return i
...
>>> f.func_defaults = (10,)
>>> f()
10
But is this officially specified behavior, or am I hitting an implementation-specific behavior?
In the documentation func_defaults
is documented as "writable", so it would seem to be defined behavior.