python: lexical or dynamic scope?

Arnaud Delobelle arnodel at googlemail.com
Tue May 13 16:25:39 EDT 2008


globalrev <skanemupp at yahoo.se> writes:

> i cant figure outif python has lexical or general scope.
>
> it seems functions have lexical scope but with some restrictions and
> some non-function scopes are dynamic?

I can't think of any instance of dynamic scoping in Python.  Can you
give an example of what you are thinking of?

AFAIK, Python has lexical scoping, with the restriction that
non-global non-local names cannot be rebound.

-- 
Arnaud



More information about the Python-list mailing list