comparing dictionaries to find the identical keys
Beema shafreen
beema.shafreen at gmail.com
Fri Dec 28 06:25:43 EST 2007
hi everybody ,
i need to compare two dictionary's key. I have written a script
gene_symbol = {}
probe_id = {}
result = {}
def getGene(fname):
fh = open(fname , 'r')
for line in fh:
yield line
fh.close()
for line in getGene("symbol_hu133"):
data1= line.strip().split('#')
probe_give = data1[0].strip()
gene_give = data1[1].strip()
gene_symbol[probe_give] = gene_give
#print gene_symbol.keys()
for line in getGene("gds1428.csv"):
data = line.strip().split(',')
probe_get = data[0].strip()
probe_id[probe_get] = data
if gene_symbol.keys() == probe_id.keys():
print gene_symbol.keys(), probe_id.values()
can anybody show me the error I make here ,while comparing the keys of two
dictionaries so that i print the values of the dictionaries whoes Keys are
Identical
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071228/97ed5b8b/attachment.html>
More information about the Python-list
mailing list