Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6736 > unrolled thread

Re: scope of function parameters (take two)

Started byTerry Reedy <tjreedy@udel.edu>
First post2011-05-31 12:15 -0400
Last post2011-05-31 12:15 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: scope of function parameters (take two) Terry Reedy <tjreedy@udel.edu> - 2011-05-31 12:15 -0400

#6736 — Re: scope of function parameters (take two)

FromTerry Reedy <tjreedy@udel.edu>
Date2011-05-31 12:15 -0400
SubjectRe: scope of function parameters (take two)
Message-ID<mailman.2318.1306858536.9059.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web