[ create a new paste ] login | about

Link: http://codepad.org/ElMP6k97    [ raw code | output | fork ]

Python, pasted on Aug 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def get_match():
    cache=[1]
    def match(v):
        try:
            if cache:
                return cache
        except NameError:
            print 'NameError caught'
            cache = [v]
        return cache
    return match
m = get_match()
print m(2)
print m(3)


Output:
1
2
3
4
NameError caught
[2]
NameError caught
[3]


Create a new paste based on this one


Comments: