Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not quite clear on what you're saying about try/except/continue in for loops. The following is loosely based on the code you provide.</p> <pre><code>def failing_func(raster): raise ValueError("raster &lt;%s&gt; function has failed" % (raster)) def working_func(raster): print("raster &lt;%s&gt; function has succeeded" % (raster)) return True raster_list = [0, 1, 2, 3, 4, 5] for raster in raster_list: print("Processing &lt;%s&gt;" % (raster)) try: v1 = working_func("raster_1") v2 = failing_func("raster_2") v3 = working_func("raster_3") v4 = failing_func("raster_4") v5 = working_func("raster_5") except ValueError, e: print("Exception was raised: %s when processing item %s" % (str(e), raster)) continue </code></pre> <p>Which outputs:</p> <pre><code>Processing &lt;0&gt; raster &lt;raster_1&gt; function has succeeded Exception was raised: raster &lt;raster_2&gt; function has failed when processing item 0 Processing &lt;1&gt; raster &lt;raster_1&gt; function has succeeded Exception was raised: raster &lt;raster_2&gt; function has failed when processing item 1 Processing &lt;2&gt; raster &lt;raster_1&gt; function has succeeded Exception was raised: raster &lt;raster_2&gt; function has failed when processing item 2 Processing &lt;3&gt; raster &lt;raster_1&gt; function has succeeded Exception was raised: raster &lt;raster_2&gt; function has failed when processing item 3 Processing &lt;4&gt; raster &lt;raster_1&gt; function has succeeded Exception was raised: raster &lt;raster_2&gt; function has failed when processing item 4 Processing &lt;5&gt; raster &lt;raster_1&gt; function has succeeded Exception was raised: raster &lt;raster_2&gt; function has failed when processing item 5 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload