Pyry Pakkanen added the comment:
Oh, I was sure it had to do with binding issues. I just couldn't put my finger
on it because the behavior seemed so counterintuitive.
Thanks for clearing things up. I can now work around this feature.
--
___
Python t
Amaury Forgeot d'Arc added the comment:
This is expected, and is due to the late binding of the "label" variable in the
"item+label" expression. Look at the example below:
>>> l = [lambda item: item + label for label in "ab"]
>>> f1, f2 = l
>>> print f1(''), f2('')
b b
For the lambda functio
New submission from Pyry Pakkanen :
The following self-referencing generator has incorrect output:
def ab_combinations():
#'', 'a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', ...
def _deferred_output():
yield ""
tees = tee(output)
#This definition works fine: '', 'a', '