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


Groups > comp.lang.python > #6736

Re: scope of function parameters (take two)

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'subject:two': 0.07; 'terry': 0.07; 'python': 0.08; 'clearly,': 0.09; 'collections': 0.09; 'manipulation': 0.09; 'mutable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:parameters': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'immutable': 0.16; 'mathematics.': 0.16; 'reedy': 0.16; 'subject:function': 0.16; 'language': 0.18; 'functions,': 0.19; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; '(without': 0.23; 'fundamental': 0.23; 'objects': 0.23; 'function': 0.25; 'parameters': 0.26; 'bound': 0.29; 'do.': 0.30; 'objects.': 0.30; 'yes.': 0.30; 'calling': 0.31; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'that,': 0.34; 'header:User-Agent:1': 0.35; 'model': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'subject: (': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'possibility': 0.40; 'simply': 0.60; 'within': 0.60; 'life,': 0.65; 'designed': 0.65; 'making': 0.67; 'associations': 0.84; 'special.': 0.84; 'adults': 0.93; 'eliminates': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: scope of function parameters (take two)
Date Tue, 31 May 2011 12:15:21 -0400
References <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@mcgill.ca> <BANLkTin5exEpDkE3on3BAaWwHOjpg_vC8g@mail.gmail.com> <6699AB10-988A-49AD-B7C1-6BAA2CC3D008@mcgill.ca>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host rain.gmane.org
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10
In-Reply-To <6699AB10-988A-49AD-B7C1-6BAA2CC3D008@mcgill.ca>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2318.1306858536.9059.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 82.94.164.166
X-Trace 1306858537 news.xs4all.nl 49174 [::ffff:82.94.164.166]:53591
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6736

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web