This usually works; however, it's not this time:
def fn(text):
def fn2():
print text
fn2()
How can I fix this?
Thanks.
Edit: I don't want to pass in text.
This usually works; however, it's not this time:
def fn(text):
def fn2():
print text
fn2()
How can I fix this?
Thanks.
Edit: I don't want to pass in text.
I would suggest reading this page: http://eli.thegreenplace.net/2011/05/15/understanding-unboundlocalerror-in-python/
So where does the exception come from? Quoting the FAQ:
This is because when you make an assignment to a variable in a scope, that variable becomes local to that scope and shadows any similarly named variable in the outer scope.