我在Python2.6中尝试过这样做,它确实“工作”了:
>>> def f(i='I'): return i
...
>>> f.func_defaults = (10,)
>>> f()
10但这是官方指定的行为,还是我遇到了特定于实现的行为?
发布于 2012-12-09 13:16:38
在the documentation中,func_defaults被记录为“可写的”,因此它似乎是已定义的行为。
https://stackoverflow.com/questions/13784840
复制相似问题