scope of function parameters

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun May 29 19:46:00 EDT 2011


On Sun, 29 May 2011 04:30:52 -0400, Henry Olders wrote:

> I just spent a considerable amount of time and effort debugging a
> program. The made-up code snippet below illustrates the problem I
> encountered:
[...]
> Are there others who feel as I do that a function parameter should
> always be local to the function? Or am I missing something here?

The nature of Henry's misunderstanding is a disguised version of the very 
common "is Python call by reference or call by value?" question that 
periodically crops up. I wrote a long, but I hope useful, explanation for 
the tutor at python.org mailing list, which I'd like to share here:

http://mail.python.org/pipermail/tutor/2010-December/080505.html


Constructive criticism welcome.


-- 
Steven



More information about the Python-list mailing list