3 ms·
"but Python supports proper closures" Is this a recent development? Without proper lexical scoping, don't you have to do weird stuff like creating an array if
by jimbokun 15y ago
"but Python supports proper closures"
Is this a recent development? Without proper lexical scoping, don't you have to do weird stuff like creating an array if you want to update a value inside a "closure"?
- Jach 15y agoOne might argue you shouldn't mix functional programming with side effects. ;P But it's not so much the case of scoping as the case of variable binding. Assignments/statements in Python don't work like they do in some other languages. So your inner function can reference the outer "x" all it wants, but you'll get problems if you try to do something like x += 1.