3 ms·
python's variable scoping is useless. i can't reassign a variable in an upper context. i can mutate the object it refers to, but i can't reassign the variable
by cracki 16y ago
python's variable scoping is useless.
i can't reassign a variable in an upper context. i can mutate the object it refers to, but i can't reassign the variable right there. instead it gets instantiated at the current level.
that's why javascript has "var". it has real lexical scoping.
IIRC python 3 has the "nonlocal" keyword to "fix" this mess, but i'm not pleased by that. i read the PEP and understand their reasoning. still, it's different behavior from what other languages do (notably scheme and js). they can't even make proper lambdas, but that's because they painted themselves into a corner with the syntax.
a freeform mode for python might solve the lambda issue... but then we'd have ruby or javascript, pretty much.
what tips the scales for me (i use python most) is libraries and environment. javascript doesn't yet have a real command line scripting experience. microsoft's windows scripting host and jscript come close, but all the library documentation is scattered throughout MSDN. i much prefer python's HTML documentation. it's terse and easy to browse.