| Tor Norbye | 3a2425a | 2013-11-04 10:16:08 -0800 | [diff] [blame^] | 1 | def f1(): |
| 2 | nonlocal <warning descr="Nonlocal variable 'x' must be bound in an outer function scope">x</warning> #fail | ||||
| 3 | |||||
| 4 | |||||
| 5 | def f2(): | ||||
| 6 | def g(): | ||||
| 7 | nonlocal <warning descr="Nonlocal variable 'x' must be bound in an outer function scope">x</warning> #fail | ||||
| 8 | print(x) | ||||
| 9 | |||||
| 10 | |||||
| 11 | x = 1 | ||||
| 12 | |||||
| 13 | def f3(): | ||||
| 14 | nonlocal <warning descr="Nonlocal variable 'x' must be bound in an outer function scope">x</warning> #fail | ||||
| 15 | x = 2 | ||||
| 16 | |||||
| 17 | |||||
| 18 | def f4(): | ||||
| 19 | x = 0 | ||||
| 20 | def g(): | ||||
| 21 | nonlocal x #pass | ||||
| 22 | x = 2 | ||||
| 23 | return x | ||||
| 24 | return g() | ||||