Iterating over a function call
gerald.britton at gmail.com
Tue Feb 2 15:47:30 CET 2010
>> 2. side effect of (maybe) leaking the iterator variable "value" into
>> the code following the loop (if the iterator is not empty).
> So? it is sometime useful.
Except that you can't guarantee that it will be set since the for loop
will not execute if the iterable is empty.
>> I can take care of 2 by explicitly deleting the variable at the end:
>> del value
>> but I'd probably forget to do that sometimes.
> So? If having 'value' bound breaks your subsequent code, I consider it
Quite so. I just like to eliminate the possibility up front. If
'value' is never bound, the the bug will show up sooner.
More information about the Python-list