<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Is there any way to check if an item in specific location in a multiple dimension nested exist?  For example something like:
<br><br>if M_list[line][row][d] exist:<br>  do_something_0<br>else:<br>  do_something_1 
<br></blockquote></div><br>Certainly:<br><code><br>try:<br>    M_list[line][row][d]<br>
except IndexError:
  <br>    do_something_1 
<br>else:<br>    do_something_0<br></code><br><br>Assuming that you want to check because something in `do_someting_0' fails if the item isn't defined, it is very likely that this can be shortened to:<br><br>
<code><br>try:<br>    do_something_0<br>except IndexError:<br>    do_something_1<br></code><br><br>The try/except should be wrapped as tightly as possible around the specific code that actually throws the exception.
<br><br>Matt<br><br>