this should work<br><br><br>def find_value(value, lst):<br> for obj in lst:<br> if value in obj.values():<br> return obj<br><br>>> find_value("aaa", my_lst)<br><br>Vince<br><br><div class="gmail_quote">
On Thu, Jul 23, 2009 at 9:55 AM, <span dir="ltr"><<a href="mailto:davidwilson@safe-mail.net">davidwilson@safe-mail.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hello,<br>
please excuse me, but i would like to understand how dictionaris work.<br>
<br>
for example:<br>
>>> my_lst = [{'code': 'aaa', 'name': 'a name'}, {'code': 'bbb', 'name': 'b name'}]<br>
>>> my_code = 'aaa'<br>
<br>
<br>
from the above i would like to compare my_code and return the dictionary which has code == my_code<br>
<br>
dave<br>
_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</blockquote></div><br>