[BangPypers] Enclosing lexical context

Noufal Ibrahim noufal at gmail.com
Thu Apr 15 19:39:29 CEST 2010

On Thu, Apr 15, 2010 at 10:36 PM, Picachu Nioto <picachu.nioto at gmail.com> wrote:
> Could some one explain to me this sentence, I read in an example online
> "Python doesn't implement assignment of variables bound in an enclosing
> lexical context"
> Example,
> a=[b]

I'm not sure where you got this sentence means but Python's scoping is
lexical but has 2 namespaces accessible from the current point of
execution (locals and globals) which are arguably dynamic. Here's an
example to show lexical scoping.


You can see that it prints 1 which is the value of the free identifier
foo lexically at the point of the print.

As a counter example, here's an example in Emacs lisp which parallels
the above but since it's dynamically scoped, the value printed is 2.


More information about the BangPypers mailing list