Clustering the keys of a dict according to its values
bdesth.quelquechose at free.quelquepart.fr
Sun Nov 16 19:45:19 CET 2008
bearophileHUGS at lycos.com a écrit :
> Bruno Desthuilliers:
>> What is data is another type of sequence or iterable ?-)<
> The original problem statement was:
I did read it, thanks.
> If the problem changes, then the code has to/can change. When you
> write code it's better to avoid over-generalization
It's not a problem of "over-generalization", it's a problem of not being
_uselessly_ restrictive. Your solution will fail with any non-list
sequence, for no good reason.
> (this is also a
> rule in Agile programming practices).
The rational behind the YAGNI rule is to avoid wasting time on useless
generalizations. This does not apply here since the more generic
solution doesn't take more time to write or maintain.
More information about the Python-list