2016-09-04 | Paul Boddie | file changeset files shortlog | Track required modules, either explicitly imported or providing dependencies, as opposed to those providing objects defined elsewhere. |
paul@2 | 1 | class C: |
paul@2 | 2 | def c(self): |
paul@2 | 3 | return 1 |
paul@2 | 4 | |
paul@2 | 5 | class D: |
paul@2 | 6 | def d(self): |
paul@2 | 7 | return 3 |
paul@2 | 8 | |
paul@2 | 9 | a = 4 |
paul@2 | 10 | |
paul@2 | 11 | def f(x): |
paul@2 | 12 | x.c() |
paul@2 | 13 | def g(y): # x introduced as default here |
paul@2 | 14 | if y: |
paul@2 | 15 | x = D() |
paul@2 | 16 | return x.d(), y, a # UnboundLocalError in Python (if y is a false value) |
paul@2 | 17 | return g |
paul@2 | 18 | |
paul@2 | 19 | result = f(C())(2) |
paul@2 | 20 | assert result == (3, 2, 4) |