| Tor Norbye | 3a2425a | 2013-11-04 10:16:08 -0800 | [diff] [blame^] | 1 | global_foo = 1 |
| 2 | |
| 3 | |
| 4 | def test_outer_function(): |
| 5 | foo = 1 |
| 6 | def bar(): |
| 7 | <weak_warning descr="Shadows name 'foo' from outer scope">foo</weak_warning>, <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning> = 1, 2 |
| 8 | def baz(<weak_warning descr="Shadows name 'foo' from outer scope">foo</weak_warning>, <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning>, <weak_warning descr="Shadows name 'baz' from outer scope">baz</weak_warning>): |
| 9 | pass |
| 10 | def nested(): |
| 11 | def <weak_warning descr="Shadows name 'baz' from outer scope">baz</weak_warning>(<weak_warning descr="Shadows name 'foo' from outer scope">foo</weak_warning>): |
| 12 | <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning> = 1 |
| 13 | |
| 14 | |
| 15 | def test_outer_class(): |
| 16 | baz = 1 |
| 17 | quux = 2 |
| 18 | spam = 3 |
| 19 | class C(object): |
| 20 | def foo(self): |
| 21 | def foo(): |
| 22 | def <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning>(): |
| 23 | class <weak_warning descr="Shadows name 'C' from outer scope">C</weak_warning>: |
| 24 | def baz(self): |
| 25 | pass |
| 26 | def bar(): |
| 27 | pass |
| 28 | |
| 29 | <weak_warning descr="Shadows name 'baz' from outer scope">baz</weak_warning> = 2 |
| 30 | |
| 31 | def spam(self): |
| 32 | pass |
| 33 | |
| 34 | quux = 1 |
| 35 | |
| 36 | |
| 37 | def test_outer_global(): |
| 38 | global global_foo |
| 39 | global_foo = 2 |
| 40 | |
| 41 | |
| 42 | def test_outer_comprehensions(): |
| 43 | print(x for x in range(10)) |
| 44 | print([y for y in range(10)]) |
| 45 | def f(x, <weak_warning descr="Shadows name 'y' from outer scope">y</weak_warning>): |
| 46 | pass |