As Lazir noted in the comments, a similar issue was posted here . Using the cluster module, the solution to my problem would be:
>>> from cluster import *
>>> L = [15,16,57,59,14]
>>> cl = HierarchicalClustering(L, lambda x,y: abs(x-y))
>>> cl.getlevel(2)
[[14, 15, 16], [57, 59]]
( ):
>>> [mean(cluster) for cluster in cl.getlevel(2)]
[15, 58]