Clustering the keys of a dict according to its values

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Nov 16 02:44:28 EST 2008


Bruno Desthuilliers:
> What is data is another type of sequence or iterable ?-)<

The original problem statement was:

Florian Brucker:
>Given a dictionary, I want to create a clustered version of it, collecting keys that have the same value: [...] Another requirement is that it should also work on lists, in that case with indices instead of keys. We may assume that all values in the original dict/list can be used as dict keys.<

If the problem changes, then the code has to/can change. When you
write code it's better to avoid over-generalization (this is also a
rule in Agile programming practices).

Bye,
bearophile



More information about the Python-list mailing list