Why is dictionary.keys() a list and not a set?

"Martin v. Löwis" martin at v.loewis.de
Fri Nov 25 23:41:59 CET 2005


Mike Meyer wrote:
> I would have phrased it as "identical" instead of equal. Sets should
> hold unique elements, where "unique" depends on the use at hand. For
> some uses, "==" might be appropriate. For others, "is" might be
> appropriate.

Sets, as currently defined, require hashable objects, i.e. objects
which has same all the time and hash same as all other equal objects.
Phrasing it as "identical" would be incorrect: hashes currently operate
on equality, not identity.

> Would you care to suggest an improved wording?

No - I have learned that I cannot write documentation that others can
understand. I usually write documentation which only attempts to be
correct, and others than make it understandable.

Regards,
Martin



More information about the Python-list mailing list