[ create a new paste ] login | about

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

Python, pasted on Jan 27:
1
2
3
4
5
6
7
8
def myfunc():
    stuff = 17
    def lfun(arg):
        print "got arg", arg, "and stuff is", stuff
        stuff += 1
    lfun(42)

myfunc()


Output:
1
2
3
4
5
6
7
8
9
got arg 42 and stuff is
Traceback (most recent call last):
  Line 8, in <module>
    myfunc()
  Line 6, in myfunc
    lfun(42)
  Line 4, in lfun
    print "got arg", arg, "and stuff is", stuff
UnboundLocalError: local variable 'stuff' referenced before assignment


Create a new paste based on this one


Comments: