Is there "let binding" in Python?

Donn Cave donn at u.washington.edu
Mon Sep 15 19:27:38 EDT 2003


In article <mailman.1063658000.4467.python-list at python.org>,
 Lulu of the Lotus-Eaters <mertz at gnosis.cx> wrote:

> 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
> their value.
> 
> 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:
> 
>     http://gnosis.cx/publish/programming/charming_python_16.html
> 
> 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.

Hm, at this point I'm concluding that you know exactly what
he's talking about and don't have any substantial argument
with it, you only object to the term "mutate".  If he had
said "rebinding" instead, all would have been well?

   Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list