Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'value,': 0.04; 'parameter': 0.05; 'subject:two': 0.07; '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; 'def': 0.12; 'described': 0.14; 'defined': 0.14; '3],': 0.16; 'bieber': 0.16; 'bound)': 0.16; 'declaimed': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'received:mindspring.com': 0.16; 'received:wlfraed': 0.16; 'runtime.': 0.16; 'subject:function': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'mon,': 0.17; 'accessible': 0.19; 'compile': 0.19; 'seems': 0.21; 'body.': 0.23; '(or': 0.24; 'url:home': 0.25; '(and': 0.25; 'function': 0.25; 'object': 0.26; 'effect': 0.29; 'lee': 0.29; 'explicitly': 0.29; 'originally': 0.29; 'variables': 0.29; 'binding': 0.30; 'nested': 0.30; 'sort': 0.31; 'header:X -Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'list': 0.33; '[1]': 0.34; 'here,': 0.35; 'problems': 0.36; 'charset:us- ascii': 0.36; 'assigned': 0.37; 'something': 0.37; 'element': 0.37; 'received:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'subject: (': 0.39; 'should': 0.39; 'unless': 0.39; 'header:Mime- Version:1': 0.39; 'list,': 0.39; 'to:addr:python.org': 0.39; 'body': 0.61; 'container': 0.73; 'encountered': 0.73; 'dennis': 0.77; 'disconnects': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: scope of function parameters (take two) Date: Mon, 30 May 2011 22:20:10 -0700 Organization: > Bestiaria Support Staff < References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: user-11fa9ub.dsl.mindspring.com X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306819808 news.xs4all.nl 49048 [::ffff:82.94.164.166]:38351 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6706 On Mon, 30 May 2011 20:28:34 -0400, Henry Olders declaimed the following in gmane.comp.python.general: > > What I would like is that the variables which are included in the function definition's parameter list, would be always treated as local to that function (and of course, accessible to nested functions) but NOT global unless explicitly defined as global. This would prevent the sort of problems that I encountered as described in my original post. I may be wrong here, but it seems that the interpreter/compiler should be able to deal with this, whether the parameter passing is by value, by reference, by object reference, or something else. If variables are not assigned (or bound) at compile time, but are included in the parameter list, then the binding can be made at runtime. But "names" in a parameter list ARE local to the body of the function... Binding a new value to that name has no effect outside the body. Mutating the contents of a container type that is associated with that name is a different matter. a = [1, 2, 3] def sample(x): x[1] = "me" #mutates the [1] element of whatever x is associated with x = "you" #rebinds the name x to a new value which disconnects #from the object originally associated to x sample(a) # a is now [1, "me", 3], not "you" -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/