On 5/31/2011 3:17 AM, Henry Olders wrote:
Clearly, making a copy within the function eliminates the possibility of
the side effects caused by passing in mutable objects.
Mutable objects and mutating methods and functions are a *feature* of
Python. If you do not like them, do not use them.
> Would having the compiler/interpreter do this automatically
> make python so much different?
Yes. How would you then write a function like list.sort or list.pop?
It is fundamental that parameters are simply local names that must be
bound as part of the calling process. After that, they are nothing special.
Python is a language for adults that take responsibility for what they
do. If you do not like argument-mutating functions, then do not write
them and do not use them (without making a copy yourself).
Python was not designed to model timeless immutable mathematics. It is
an information-object manipulation language and in real life, we mutate
collections and associations all the time.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list