Clustering the keys of a dict according to its values

Bruno Desthuilliers bdesth.quelquechose at
Sun Nov 16 19:45:19 CET 2008

bearophileHUGS at 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 mailing list