nested scopes
Michael Hudson
mwh21 at cam.ac.uk
Tue Feb 6 15:35:09 EST 2001
"Rainer Deyke" <root at rainerdeyke.com> writes:
> "Michael Hudson" <mwh21 at cam.ac.uk> wrote in message
> news:m3r91b3b5b.fsf at atrus.jesus.cam.ac.uk...
> > It's good when you're calling a function (call it A) that calls
> > another function (call this one B) that has parameterizable behaviour,
> > because A doesn't have to put all of B's parameters in its argument
> > list - you get B to read these paramters from special (ie. dynamically
> > scoped) variables and bind them around your call to A. Can't think of
> > a real good example now, I'm afraid. The Common Lisp printer uses
> > special variables extensively.
>
> Some Python functions (including 'globals' and 'locals') have behavior
> similar to that of dynamic scoping.
How so? Note I'm using "dynamic scope" in a pretty technical sense
here - "indefinite scope and dynamic extent". Python variables have
definite scope and dynamic extent (although the objects they point to
have indefinite extent).
Here's a reference:
http://ringer.cs.utsa.edu/research/AI/cltl/clm/node43.html
Cheers,
M.
--
ARTHUR: Why should he want to know where his towel is?
FORD: Everybody should know where his towel is.
ARTHUR: I think your head's come undone.
-- The Hitch-Hikers Guide to the Galaxy, Episode 7
More information about the Python-list
mailing list