Is there "let binding" in Python?
Lulu of the Lotus-Eaters
mertz at gnosis.cx
Mon Sep 15 22:23:58 CEST 2003
Rob Hunter <rhunter007 at yahoo.com> wrote previously:
|The FOR statement is mutating the variable i.
|In general, in most cases, I find it *unacceptable* to use mutation.
Nope, Nope, No!
In Python, integers are IMMUTABLE. Nothing anywhere will ever change
What the 'for' statement does is BIND a value to a name. Same thing an
assignment does, and so on.
Some values are mutable, like lists and dictionaries. But it seems like
most of what Hunter writes is just a misunderstanding of the difference
between mutation and binding.
If you like, you can create a 'let'-like prohibition on rebinding. See:
The version on dW has the code samples messed up now. But you do not
usually want to do this. It's just superfluous and contrived, rather
than useful, mostly.
_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: Postmodern Enterprises _/_/_/
_/_/ ~~~~~~~~~~~~~~~~~~~~[mertz at gnosis.cx]~~~~~~~~~~~~~~~~~~~~~ _/_/
_/_/ The opinions expressed here must be those of my employer... _/_/
_/_/_/_/_/_/_/_/_/_/ Surely you don't think that *I* believe them! _/_/
More information about the Python-list