Suppose I would like to loop over an array and within the loop index the array forward and backward for all of its indices like so:
x = np.random.uniform(size=600)
for i in range(len(x)):
dot = np.dot(x[:-i], x[i:])
Now this doesn't work, because x[:-0] is just like x[:0] which gives [].
I could handle the zero case separately but was wondering whether there's a more pythonic way of doing this.