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


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

Re: scope of function parameters

Started byTerry Reedy <tjreedy@udel.edu>
First post2011-05-29 18:20 -0400
Last post2011-05-29 18:20 -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 Terry Reedy <tjreedy@udel.edu> - 2011-05-29 18:20 -0400

#6588 — Re: scope of function parameters

FromTerry Reedy <tjreedy@udel.edu>
Date2011-05-29 18:20 -0400
SubjectRe: scope of function parameters
Message-ID<mailman.2241.1306707648.9059.python-list@python.org>
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

[toc] | [standalone]


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


csiph-web