lambda in list comprehension acting funny

Dan Stromberg drsalists at
Sun Jul 15 02:11:19 CEST 2012

On Sat, Jul 14, 2012 at 4:29 PM, Steven D'Aprano <
steve+comp.lang.python at> wrote:

> I don't remember whether it is Javascript or PHP that uses dynamic
> binding, but whichever it is, it is generally considered to be a bad
> idea, at least as the default or only behaviour.
> Bash is another language with dynamic binding. Some very old versions of
> Lisp use dynamic binding, because it was the easiest to implement. Most
> modern languages use lexical (also known as static) binding, because it
> is more sensible.
> Here is an illustration of the difference: suppose we have two modules,
> and
> #
> x = 23
> def func(y):
>     return x + y
> #
> import library
> x = 1000
> print func(1)

I've not heard this discussed  in a while.  ISTR it was "lexical scoping"
vs "dynamic scoping", but I wouldn't be surprised at all if it's known by
both pairs of names.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list