def make_range_partition(min_val, max_val):
    """
    Returns a new partitioning function that partitions keys in the range
    *[min_val:max_val]* into equal sized partitions.

    The number of partitions is defined by the *partitions* parameter
    """
    r = max_val - min_val
    f = ("lambda k_n_p: int(round(float(int(k_n_p[0]) - {0}) / {1} * (k_n_p[1] - 1)))"
         .format(min_val, r))
    return eval(f)