title: Index in function causing error with function has no attribute getitim
body: <p>I'm a python beginner and I am attempting to write a function which computes the nearest neighbours of a lattice point, and am recieving the following error:</p>
  
  <blockquote>
    <p>lattice[x, (y - 1) % N] + lattice[x, (y + 1) % N]</p>
    
    <p>TypeError: 'function' object has no attribute '<strong>getitem</strong>'</p>
  </blockquote>
  
  <p>Any solutions I've found online seem to be to do with passing a function instead of its results, but I can't see how that is happening here.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>def lattice(N):
      lattice = np.random.rand(N,N)
      lattice = np.where(lattice &lt;= 0.5, 1,-1)
  
  
  def nearestneighbours(lattice, x, y):
      return lattice[(x - 1) % N, y] + lattice[(x + 1) % N, y] + \
         lattice[x, (y - 1) % N] + lattice[x, (y + 1) % N]
  </code></pre>