On 5/18/07, Matt Smith <[EMAIL PROTECTED]> wrote:

> I am not sure
> how to suppress or avoid this error so that neighbour_count is not
> incremented for indexes outside the matrix.

Something like this:

try:
   the_index_outside_matrix_test()
except IndexError:
  suppress_the_error()

> Is there a better way of doing this?

Perhaps something like this:

for n in (x, x+1, x-1):
  for m in (y, y+1, y-1):
    if matrix[n, m]:
      neighbour_count = neighbour_count + 1



-- 
- Rikard - http://bos.hack.org/cv/
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to