[CentralOH] Breaking Out Of Nested Loops

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Wed Jul 6 23:02:19 EDT 2016


On Wed, 6 Jul 2016 18:03:04 -0400, jep200404 at columbus.rr.com wrote:

> James Prior presented:
> 
>     A technique for breaking out of nested loops
>     by using a generator to yield tuples of values.
> 
>         http://nbviewer.jupyter.org/github/cohpy/challenge-201605-generators/blob/master/james-prior/b-break-out-of-nested-loops.ipynb

Travis Risner mentioned a technique using try and raise
from "Python Pocket Reference" by Mark Lutz.

I am guessing that the nested loops would be inside a try
clause and a raise statement would be used instead of 
a break. What is the recommended exception to raise?
Does putting nested loops inside a try clause 
rub PEP8 the wrong way?

Travis, what does the book say?


More information about the CentralOH mailing list