Odd closure issue for generators

Aahz aahz at pythoncraft.com
Fri Jun 5 09:24:38 EDT 2009


In article <h0ahkb$hee$1 at lust.ihug.co.nz>,
Lawrence D'Oliveiro  <ldo at geek-central.gen.new_zealand> wrote:
>In message 
><78180b4c-68b2-4a0c-8594-50fb1ea2f414 at c19g2000yqc.googlegroups.com>, Michele 
>Simionato wrote:
>>
>> The crux is in the behavior of the for loop: in Python there is a
>> single scope and the loop variable is *mutated* at each iteration,
>> whereas in Scheme (or Haskell or any other functional language) a new
>> scope is generated at each iteration and there is actually a new loop
>> variable at each iteration: no mutation is involved.
>
>I think it's a bad design decision to have the loop index be a variable
>that can be assigned to in the loop.

Why?
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Given that C++ has pointers and typecasts, it's really hard to have a
serious conversation about type safety with a C++ programmer and keep a
straight face.  It's kind of like having a guy who juggles chainsaws
wearing body armor arguing with a guy who juggles rubber chickens wearing
a T-shirt about who's in more danger."  --Roy Smith, c.l.py, 2004.05.23



More information about the Python-list mailing list