>> def f(): return ((lambda x=1: x), (lambda x=2: x)) >> f1, f2 = f() >> id(f1.func_code) != id(f2.func_code) The above does not hold true. It should according to test_compile (reported in HEAD as bug #1048870).
Logged In: YES user_id=1038590 This seems to be the least of lambda's problems. A number of regression tests currently fail with UnboundLocalErrors, after an argument of the form "lambda (x, y): x" is passed to a function for invocation. Assigning to myself, since I'm about to take a look at the current misbehaviour of lambdas (they must be simpler than genexps, right?)
Logged In: YES user_id=1038590 For the code above, Python 2.4.1 actually generates a single code object (that is, the comparison returns False). Looking closer at 1048870, this is expected, as the two lambdas are created on the same line. I'll look into this on the AST branch - I suspect the culprit may be our problems with getting the line numbering right. (FWIW, I worked out the UnboundLocal problem, and followed it up in the relevant bug, 1186353)
Logged In: YES user_id=1038590 The same fix mwh used for HEAD appears to work for the AST branch, too (it's just in a different source file). Patch attached, and kicking in Brett's direction for review.