with every iteration your previous values are overwritten ('md' is a dictionary) so thats why your are observing this ouput..<br><br>check if the following patch solves your problem<br><br>for entity in temp:<br>
md['module']= entity.addr.get('module')<br>
md['id']=entity.addr.get('id')<br>
md['type']=entity.addr.get('type')<br>
#print md<br>
mbusentities.append(md)<br>
md = {}<br>
#print mbusentities<br><br><br>Regards<br>Abhi<br><br><br><br><br><div><span class="gmail_quote">On 7/5/07, <b class="gmail_sendername">Hardy</b> <<a href="mailto:hhartwig@gmail.com">hhartwig@gmail.com</a>
> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I experience a problem with append(). This is a part of my code:<br><br> for entity in temp:
<br> md['module']= entity.addr.get('module')<br> md['id']=entity.addr.get('id')<br> md['type']=entity.addr.get('type')<br> #print md
<br> mbusentities.append(md)<br> #print mbusentities<br><br>I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},<br>{'module': 'work', 'id': 456, 'type': 'core'}]
<br>md is always correct, BUT:mbusentities is wrong. Length of<br>mbusentities is same of temp, so it appended everything. BUT:<br>mbusentities only shows the values of the last append: [{'module':<br>'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
<br>'type': 'core'}]<br><br>What's wrong?<br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br>