<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">When creating a list of dictionaries through a loop, I ran into a strange issue. I'll let the code talk:<br><br>&gt;&gt;&gt; l = 'i am a special new list'.split()<br>&gt;&gt;&gt; t = []<br>&gt;&gt;&gt; for thing in l:<br>...&nbsp;&nbsp;&nbsp;&nbsp; t.append({thing: 1})<br>... <br>&gt;&gt;&gt; t<br>[{'i': 1}, {'am': 1}, {'a': 1}, {'special': 1}, {'new': 1}, {'list': 1}]<br><br>This is what I expected. {} says to make a dictionary. Thing, not being quoted, is clearing a variable, which needs to be evaluated and used as the key.<br><br>&gt;&gt;&gt; t = []<br>&gt;&gt;&gt; for thing in l:<br>...&nbsp;&nbsp;&nbsp;&nbsp; t.append(dict(thing=1))<br>... <br>&gt;&gt;&gt; t<br>[{'thing': 1}, {'thing': 1}, {'thing': 1}, {'thing': 1}, {'thing': 1}, {'thing': 1}]<br><br>This was what threw me. Why would the
 dict() function not evaluate thing? How can it take it as a literal string without quotes?<br><br><br>Thanks for any insight,<br>Sam<br><div>&nbsp;</div>_______________________<br>Samuel Huckins<br><br><div>Homepage - http://samuelhuckins.com<br>Tech blog - http://dancingpenguinsoflight.com/<br>Photos - http://www.flickr.com/photos/samuelhuckins/<br>AIM - samushack | Gtalk - samushack | Skype - shuckins<div><br></div></div></div></body></html>