[Python-ideas] binding vs rebinding

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Feb 5 18:52:04 CET 2009


On Thu, Feb 5, 2009 at 17:12, Mark Dickinson <dickinsm at gmail.com> wrote:

> 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?

It would be bound locally to the body of the loop.

-- 
Marcin Kowalczyk
qrczak at knm.org.pl
http://qrnik.knm.org.pl/~qrczak/



More information about the Python-ideas mailing list