This will always select the first and last items:
which_idxs = lambda m, n: np.rint( np.linspace( 1, n, min(m,n) ) - 1 ).astype(int) evenly_spaced = np.array( your_list )[which_idxs(m,n)]
This will select only a maximum of n elements if m is greater than n. If you really want it to be evenly distributed throughout the array, even at the ends, then this would be the following:
which_idxs = lambda m, n: [idx for idx in np.rint( np.linspace( 1-n/(2*min(m,n)), n+n/(2*min(m,n)), min(m,n)+2 ) - 1 ).astype(int) if idx in range(n)] evenly_spaced = np.array( your_list )[which_idxs(m,n)]
Which gives you something like this:
>>> np.array( [1, 2, 3, 'a', 'b', 'c'] )[which_idxs(m,n)] Out: array(['2', 'b'])
Default picture
source share