I have a headache with this python code.
print "length:", len(pub)
pub_dict = dict((p.key, p) for p in pub)
print "dict:", len(pub_dict)
If I understand this right, I get a dictionary containing the attribute p.keyas a key, and the object pis its value for each element pub. Is there a side effect that I don't see? Because it len(pub_dict)should be the same as len(pub), and this, of course, is not here, or am I mistaken?
source
share