def rotate_dimensions(num_dims, src_dim, dest_dim):
 dim_list = range(num_dims)
 step = (1 if (dest_dim > src_dim) else (-1))
 for x in xrange(src_dim, dest_dim, step):
  (dim_list[x], dim_list[(x + step)]) = (dim_list[(x + step)], dim_list[x])
 return dim_list

def rotate_dimensions ( num_dims , src_dim , dest_dim ) : dim_list = range ( num_dims ) step = ( 1 if ( dest_dim > src_dim ) else ( - 1 ) ) for x in xrange ( src_dim , dest_dim , step ) : ( dim_list [ x ] , dim_list [ ( x + step ) ] ) = ( dim_list [ ( x + step ) ] , dim_list [ x ] ) return dim_list
returns a list of dimension indices that will rotate src_dim to dest_dim .