File: test_nested_scopes.py

package info (click to toggle)
decompyle 2.3.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,320 kB
  • ctags: 66,234
  • sloc: python: 70,351; ansic: 2,312; makefile: 49; sh: 14
file content (95 lines) | stat: -rw-r--r-- 1,656 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# test_nested_scopes.py -- source test pattern for nested scopes
#
# This source is part of the decompyle test suite.
#
# decompyle is a Python byte-code decompiler
# See http://www.goebel-consult.de/decompyle/ for download and
# for further information

from __future__ import nested_scopes

blurb = 1

def k0():
    def l0(m=1):
        print
    l0()

def x0():
    def y0():
        print
    y0()

def x1():
     def y1():
         print 'y-blurb =', blurb
     y1()

def x2():
    def y2():
        print
    blurb = 2
    y2()

def x3a():
    def y3a(x):
        print 'y-blurb =', blurb, flurb
    print
    blurb = 3
    flurb = 7
    y3a(1)
    print 'x3a-blurb =', blurb

def x3():
    def y3(x):
        def z():
            blurb = 25
            print 'z-blurb =', blurb,
        z()
        print 'y-blurb =', blurb,
    print
    blurb = 3
    y3(1)
    print 'x3-blurb =', blurb

def x3b():
    def y3b(x):
        def z():
            print 'z-blurb =', blurb,
        blurb = 25
        z()
        print 'y-blurb =', blurb,
    print
    blurb = 3
    y3b(1)
    print 'x3-blurb =', blurb

def x4():
    def y4(x):
        def z():
            print 'z-blurb =', blurb
        z()
    global blurb
    blurb = 3
    y4(1)

def x():
    def y(x):
        print 'y-blurb =', blurb
    blurb = 2
    y(1)


def func_with_tuple_args6((a,b), (c,d)=(2,3), *args, **kwargs):
    def y(x):
        print 'y-a =', a
    print c

def find(self, name):
    # This is taken from 'What's new in Python 2.1' by amk
    L = filter(lambda x, name: x == name, self.list_attribute)

x0(); x1(); x2();
x3(); x3a(); x3b();
x4(); x()
print 'blurb =', blurb