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


Groups > comp.lang.python > #6690

Re: scope of function parameters (take two)

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!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; '"if': 0.04; 'parameter': 0.05; 'behave': 0.07; 'names.': 0.07; 'subject:two': 0.07; 'terry': 0.07; 'python': 0.08; 'accidentally': 0.09; 'prevents': 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; 'variables.': 0.09; 'pm,': 0.10; '>>>': 0.12; 'def': 0.12; 'wrote:': 0.14; 'defined': 0.14; '"private"': 0.16; "'a'": 0.16; 'asking.': 0.16; 'function?': 0.16; 'lexical': 0.16; 'narrow': 0.16; 'reedy': 0.16; 'subject:function': 0.16; 'sections': 0.16; 'accessible': 0.19; 'before.': 0.19; 'part,': 0.19; 'programming': 0.19; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'variable': 0.21; 'wrote': 0.22; 'trying': 0.23; 'url:wiki': 0.23; 'do,': 0.25; '(and': 0.25; 'function': 0.25; 'expect': 0.25; 'loaded': 0.26; 'modules': 0.26; '"the': 0.28; 'mode': 0.29; 'are.': 0.29; 'explicitly': 0.29; 'fine.': 0.29; 'interact': 0.29; 'variables': 0.29; 'false.': 0.30; 'modifying': 0.30; 'nested': 0.30; 'entry': 0.31; 'define': 0.31; 'header:X-Complaints-To:1': 0.32; 'to:addr :python-list': 0.33; 'break': 0.33; 'with.': 0.33; 'actually': 0.33; 'there': 0.35; 'header:User-Agent:1': 0.35; 'considered': 0.36; 'idea': 0.36; 'probably': 0.36; 'issue': 0.37; 'change': 0.37; 'bother': 0.37; 'url:en': 0.37; 'another': 0.37; 'received:org': 0.38; 'url:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'doing': 0.39; 'subject: (': 0.39; 'should': 0.39; 'unless': 0.39; 'header:Mime-Version:1': 0.39; 'either': 0.39; 'list,': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'back': 0.63; 'believe': 0.66; 'making': 0.67; 'address,': 0.71; 'period.': 0.73; 'programs,': 0.80; 'yours': 0.84; 'variations,': 0.84; 'dealt': 0.91; 'distance.': 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 Mon, 30 May 2011 21:30:39 -0400
References <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@mcgill.ca>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; 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 <F4EAD1ED-563D-4D6E-A50C-68308A9F26B7@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.2285.1306805452.9059.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 82.94.164.166
X-Trace 1306805453 news.xs4all.nl 49045 [::ffff:82.94.164.166]:40937
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6690

Show key headers only | View raw


On 5/30/2011 8:28 PM, Henry Olders wrote:


> Sadly, I feel that the main issue that I was trying to address, has
> not been dealt with.

False. Please go back and read what I and others wrote before.

...
> 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)

You would like Python to be the way it is. Fine. For the Nth time,
PARAMATER NAMES ARE LOCAL NAMES. Period.

> but NOT global unless explicitly defined as global.

PARAMETER NAMES **CANNOT** BE DEFINED AS GLOBAL.

 >>> def f(a):
	global a
	
SyntaxError: name 'a' is parameter and global

Again, go back and reread what I and other wrote. I believe that you 
are, in part, hypnotized by the work 'variable'. Can you define the 
word? There are 10 to 20 possible variations, and yours is probably 
wrong for Python.

> quote from wikipedia: "It is considered good programming practice to
> make the scope of variables as narrow as feasible so that different
> parts of a program do not accidentally interact with each other by
> modifying each other's variables.

 From 'import this':
"Namespaces are one honking great idea -- let's do more of those!
Python is loaded with namespaces.

 > Doing so also prevents action at a
> distance. Common techniques for doing so are to have different
> sections of a program use different namespaces, or to make individual
> variables "private" through either dynamic variable scoping or
> lexical variable scoping."
> (http://en.wikipedia.org/wiki/Variable_(programming)#Scope_and_extent).

Python is lexically scoped.

> another quote from the wikipedia entry for Common Lisp: "the use of
> lexical scope isolates program modules from unwanted interactions.

Python is lexically scoped.

> If making python behave this way is impossible,

How do you expect us to respond when you say "Please make Python the way 
it is."? Or is you say "If making Python the way it is is impossible..."?

Now, if you actually want Python to drastically change its mode of 
operation and break most existing programs, do not bother asking.

 > Are there others who feel as I do that a
> function parameter should always be local to the function?

Yes, we all do, and they are.

-- 
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-30 21:30 -0400

csiph-web