Comparing value in two dictionaries?

Gilles Ganault nospam at nospam.com
Sat Nov 15 08:52:17 EST 2008


Hello

I fill two dictionaries with the same number of keys, and then need to
compare the value for each key, eg.

#Pour chaque APE, comparaison societe.ape.nombre et verif.ape.nombre
import apsw

#============
dic1={}
[...]
rows=list(cursor.execute(sql))
for id in rows:
	dic1[id[0]] = id[1]
#============
dic2={}
[...]
rows=list(cursor.execute(sql))
for id in rows:
	dic2[id[0]] = id[1]
#============
#Here, compare each key/value to find values that differ
for i in dic1.items():
	[...]
		
What would be a good way to do this in Python?

Thank you.



More information about the Python-list mailing list