>> for line in f:
>>     if isDefinition:
>>        gloss[currentKey] = line
>>        currentKey = None
>>        isDefinition = False
>>     else:
>>        currentKey = line
>>        isDefinition = True
>>   
> Or you can use next():
> 
> for line in f:
>    gloss[line] = f.next()

Ah! Indeed you can. I'd forgotten about that neat feature of iterators. 
No longer are for loops broken when you mess around with the 
iterated item.

Good catch Bob.

Alan G.



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to