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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With