lambda in list comprehension acting funny
drsalists at gmail.com
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 pearwood.info> wrote:
> 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,
> library.py and main.py:
> # library.py
> x = 23
> def func(y):
> return x + y
> # main.py
> 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...
More information about the Python-list