2010-06-05 | Paul Boddie | file changeset files shortlog | Changed parameter initialisation to explicitly use Instance() instead of None. Made the default parameter value code use the same mechanisms as other attribute-setting code. Added tests of lambdas and nested functions with locally defined defaults. |
paul@329 | 1 | #!/usr/bin/env python |
paul@329 | 2 | |
paul@329 | 3 | def make_add(x): |
paul@329 | 4 | return lambda a, b=x: a + b |
paul@329 | 5 | |
paul@329 | 6 | def g(f, x): |
paul@329 | 7 | return f(x) |
paul@329 | 8 | |
paul@329 | 9 | add_2 = make_add(2) |
paul@329 | 10 | result_3 = add_2(1) |
paul@329 | 11 | result2_3 = g(add_2, 1) |
paul@329 | 12 | |
paul@329 | 13 | # vim: tabstop=4 expandtab shiftwidth=4 |