<div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>&gt; I understand f.next(), but [gloss.setdefault(l,f.next()) for l in f]<br>&gt; is beyond me at this point.
<br>[expr for l in f] is a &quot;list comprehension&quot;. expr is an expression that<br>may involve l.<br><br>result = [expr for l in f] # is equivalent to:<br><br>result = []<br>for l in f:<br>&nbsp;&nbsp;&nbsp;&nbsp;result.append(expr)<br>
<br>&quot;list comprehension&quot; (once understood) is often easier to read and more<br>efficient than the for loop.<br><br>result = xxx.setdefault(key, newvalue) is a dictionary method that tries<br>to get an item from the dictionary xxx using key. If the key is not in
<br>the dictionary it adds the item assigning it newvalue. Equivalent to:<br><br>if key not in xxx:<br>&nbsp;&nbsp;&nbsp;&nbsp;xxx[key] = newvalue<br>result = xxx[key]<br><br>Note that list comprehension and setdefault both return something. In my
<br>code the returned values are ignored. The outcome (populating a<br>dictionary via a loop) is a &quot;side effect&quot;.<br></blockquote></div><br>
Thank you Bob.&nbsp; This is much to think about.&nbsp; I very much appreciate your concise explanation.<br>