4 ms·
You may need to add a 'global' statement or something similiar. If you are going to mutate a variable in a function Python assumes that you want to create a ne
by eru 18y ago
You may need to add a 'global' statement or something similiar. If you are going to mutate a variable in a function Python assumes that you want to create a new variable in that scope.
Generally I do not mutate variables as far as possible, so I have not hit this problem myself, yet. Perhaps there is someone more knowledgeable about Python to step in.
- silentbicycle 18y agoBut it's not a global variable, it's scoped within the closure. So, this means Python doesn't have lexical scoping?
- eru 18y agoIt has. Just the syntax was a bit awkward when modifying variables of higher scope. See sibling comment.