I ran into an issue with an inner function I wrote regarding variable scope. I've managed to simply the code down to point to the exact problem. So starting with:
if __name__ == "__main__":
function = outer("foo")
I'll get the expected output of :
However, if I try and re-assign foo, I get an error:
foo = "edited " + foo
UnboundLocalError: local variable 'foo' referenced before assignment
This reminds me of globals, where you can "read" them normally but to "write" you have to do "global variable; variable=...". Is it the same situation? If so, is there a keyword that allows modification of foo from within inner?