[Python-ideas] For-loop variable scope: simultaneous possession and ingestion of cake
greg.ewing at canterbury.ac.nz
Sun Oct 5 03:04:40 CEST 2008
Leif Walsh wrote:
> If I might suggest that the legacy way is not necessarily the right
> way, 'let' feels kind of like a variable declaration
It *is* a variable declaration.
If you're saying it's not *only* a variable declaration,
that's true, but it's also true in other languages that
> I am mostly wary of new users discovering 'let' and using
> it everywhere because they don't understand what it means.
It wouldn't do much harm if they did -- there's no semantic
or performance difference if the variable isn't referenced
from a nested function.
It could even be considered helpful if it makes it clear
that a particular temporary variable is only used in
a certain region of the code.
More information about the Python-ideas