paul@2 | 1 | a = 4 |
paul@2 | 2 | |
paul@2 | 3 | def f(x): |
paul@266 | 4 | |
paul@266 | 5 | # Test function initialisation (f.$l0). |
paul@266 | 6 | |
paul@43 | 7 | def g(y, x=x): |
paul@266 | 8 | |
paul@266 | 9 | # Test function initialisation (f.$l0.$l0). |
paul@266 | 10 | |
paul@43 | 11 | def h(a, z, x=x, y=y): |
paul@43 | 12 | return x, y, z, a # parameter a overrides global scope |
paul@266 | 13 | |
paul@2 | 14 | return h |
paul@266 | 15 | |
paul@2 | 16 | return g |
paul@2 | 17 | |
paul@266 | 18 | fn = f(1) |
paul@266 | 19 | print fn # __main__.f.$l0 |
paul@266 | 20 | print fn(2) # __main__.f.$l0.$l0 |
paul@266 | 21 | print fn(2)(5, 3) # (1, 2, 3, 5) |
paul@266 | 22 | print fn(2)(5, 3, 6) # (6, 2, 3, 5) |
paul@266 | 23 | print fn(2)(5, 3, 6, 7) # (6, 7, 3, 5) |