question about scope
John Salerno
johnjsal at NOSPAMgmail.com
Thu Feb 16 10:31:44 EST 2006
John Salerno wrote:
> I understand what global and built-in are, and I thought I understood
> the concept of local too, but when I got to this sentence (and the
> previous sentence), I became confused about the first two scopes. What's
> the difference between 'local' and 'enclosing functions'?
I guess maybe I jumped the gun. Here's some stuff later in the chapter
that I think explains it for me:
----------
Note that the second 'E' scope lookup layer -- enclosing defs or lambdas
-- technically can correspond to more than one lookup layer. It only
comes into play when you nest functions within functions.*
* The scope lookup rule was known as the "LGB" rule in the first edition
of this book. The enclosing def layer was added later in Python, to
obviate the task of passing in enclosing scope names explicitly --
something usually of marginal interest to Python beginners.
----------
More information about the Python-list
mailing list