>> The answer is really really simple. The implementation of copy predates >> mutability. When the copy code was written, functions *were* immutable. >> When functions became mutable, the copy code was not changed, and >> nobody noticed or complained. > > That's probably an indication that mutable functions don't > get used all that much. Are there any instances of them in the > standard Python libraries?
All user-defined functions are mutable. To me, this issue is rather that copying of functions isn't used all that much. In addition, it is certainly true that functions are rarely modified, even though all of them are mutable. See this for an example py> def foo():pass ... py> foo <function foo at 0xb7db5f44> py> foo.__name__='bar' py> foo <function bar at 0xb7db5f44> py> foo.value Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'function' object has no attribute 'value' py> foo.value=100 py> foo.value 100 Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list