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


Groups > comp.lang.python > #6588

Re: scope of function parameters

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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; '(although': 0.05; 'parameter': 0.05; 'args': 0.07; 'terry': 0.07; 'variable,': 0.07; 'python': 0.08; '*args': 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; 'pm,': 0.10; '>>>': 0.12; 'def': 0.12; 'wrote:': 0.14; '(either': 0.16; 'local.': 0.16; 'reedy': 0.16; 'subject:function': 0.16; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'function': 0.25; 'parameters': 0.26; 'functions.': 0.29; 'header:X-Complaints- To:1': 0.32; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.35; 'assignment': 0.35; 'considered': 0.36; 'assigned': 0.37; 'case': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'exact': 0.65
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: scope of function parameters
Date Sun, 29 May 2011 18:20:30 -0400
References <F8395F78-615E-4FBD-B6FC-1D6173EAEA45@mcgill.ca> <201105291147.26545.wolfgang@rohdewald.de> <371A067F-540A-46C3-820C-4348B9815AB9@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 <371A067F-540A-46C3-820C-4348B9815AB9@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.2241.1306707648.9059.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 82.94.164.166
X-Trace 1306707649 news.xs4all.nl 49182 [::ffff:82.94.164.166]:58660
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6588

Show key headers only | View raw


On 5/29/2011 4:19 PM, Henry Olders wrote:

> From my perspective, a function parameter should be considered as
> having been assigned (although the exact assignment will not be known
> until runtime), and as an assigned variable, it should be considered
> local.

That is exactly the case for Python functions.

 >>> def f(a,b):
	c,d = 3,4
	print(locals())

 >>> f.__code__.co_varnames # local names
('a', 'b', 'c', 'd')
 >>> f(1,2)
{'a': 1, 'c': 3, 'b': 2, 'd': 4}

The requirement for a function call is that all parameters get an 
assignment and that all args are used in assignments (either directly by 
position or keyname or as part of a *args or **kwds assignment).

-- 
Terry Jan Reedy

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


Thread

Re: scope of function parameters Terry Reedy <tjreedy@udel.edu> - 2011-05-29 18:20 -0400

csiph-web