Weird lambda behavior (bad for)

Aahz aahz at pythoncraft.com
Sun Apr 26 18:30:17 CEST 2009


In article <gt0d15$167c$1 at adenine.netfront.net>,
namekuseijin  <namekuseijin.nospam at gmail.com> wrote:
>
>I don't like *for* at all.  It both makes it tough to get true closures 
>and also unnecessarily pollutes the namespace with non-local variables.

Maybe.  Consider this standard Python idiom:

for x in L:
    if x == criterion:
        break
doSomething(x)

Obviously, this case could be rewritten fairly easily to hoist
doSomething into the loop before the break, but I've seen other cases
less amenable.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur."  --Red Adair



More information about the Python-list mailing list