I have this code (need to subtract sum of previous elements from current):
arr = np.zeros((N,M,T))
for it in xrange(T):
sum_arr = np.zeros((M,N))
for tt in xrange(it): sum_arr += arr[:,:,tt]
arr[:,:,it] -= sum_arr
Question: Is it way to write this code in pythonic way (prefer one line)? Thx in advance.