Valid link in my previews message is
http://mail.python.org/pipermail/python-dev/2005-September/056669.html
Sorry.
--
http://mail.python.org/mailman/listinfo/python-list
OK.
The thing i've got is an obscure semantic bug, occured because of my
unawareness of the following Python "features":
1. (In major)
http://mail.python.org/pipermail/python-dev/2005-September/056508.html
2. "late" bindings of the function's body
Got to know! :)
Thanks for your attention.
--
h
Max Rybinsky <[EMAIL PROTECTED]> wrote:
> Thank you for explanation, Alex.
> It appears that almost every beginner to Python gets in trouble with
> this ...feature. :)
Almost every beginner to Python gets in trouble by expecting "do what
I'm thinking of RIGHT NOW"-binding, which no language offer
Thank you for explanation, Alex.
It appears that almost every beginner to Python gets in trouble with
this ...feature. :)
--
http://mail.python.org/mailman/listinfo/python-list
On 29 Oct 2005 14:25:24 -0700, Max Rybinsky <[EMAIL PROTECTED]> wrote:
>Hello!
>
>Please take a look at the example.
>
a = [(x, y) for x, y in map(None, range(10), range(10))] # Just a list of
tuples
a
>[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8,
>8), (9, 9)
Max Rybinsky <[EMAIL PROTECTED]> wrote:
...
> >>> funcs = [lambda n: x * y / n for x, y in a]
...
> It seems, all functions have x and y set to 9.
> What's wrong with it? Is it a bug?
It's known as *late binding*: names x and y are looked up when the
lambda's body is executing, and at that t
Hello!
Please take a look at the example.
>>> a = [(x, y) for x, y in map(None, range(10), range(10))] # Just a list of
>>> tuples
>>> a
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8,
8), (9, 9)]
Now i want to get a list of functions x*y/n, for each (x, y) in a:
>>> funcs