[Python-ideas] binding vs rebinding
Mark Dickinson
dickinsm at gmail.com
Thu Feb 5 17:12:17 CET 2009
On Thu, Feb 5, 2009 at 1:22 PM, spir <denis.spir at free.fr> wrote:
> Hello,
>
> I wonder why there is no difference in syntax between binding and rebinding. Obviously, the semantics is not at all the same, for humans as well as for the interpreter:
> * Binding: create a name, bind a value to it.
> * Rebinding: change the value bound to the name.
>
> I see several advantages for this distinction and no drawback.
How would you write code like:
my_result = []
for item in items:
a = <some intermediate result computed from item>
...
my_result.append(<something computed from a>)
where a is bound for the first time on the first iteration
of the loop, and rebound on all subsequent iterations?
Mark
More information about the Python-ideas
mailing list