title: Python find list of surrounding neighbours of a node in 2D array
body: <p>I've been working on a code (Py 2.7) that generates an array of elements with each node assigned some random numbers. Now, I wish to make a list of the surrounding elements, and find the index of the max value. The array size is variable (I considered col = array column size). I have assigned numbers to each node (I called it 's' in the below) so that I can find the 2D index of the array element. Here is what I wrote</p>
  
  <pre><code>rn = s/col; cn = s%col;
  b = [rr[rn,cn+1],rr[rn-1,cn+1],rr[rn-1,cn],rr[rn-1,cn-1],rr[rn,cn-1],rr[rn+1,cn-1],rr[rn+1,cn],rr[rn+1,cn+1]]
  ma = max(b)
  a = [i for i,j in enumerate(b) if j == ma]
  </code></pre>
  
  <p>Is there any short method to find the neighbours without the need to number each array element ? (like I did using s). </p>