Python: Continuing to next iteration in outer loop -


I wanted to know that in Python there are no built-in ways to continue the next recurrence in the external loop, for example, code Consider:

  in range (200): For JS range (200, 400): ... block0 ... if anything: Continue ... block1 ... < / Code> 

I want to issue a statement that JG should exit the loop and ii get the next item in the loop. I can apply this argument in some other way (by setting a flag variable), but is there an easy way to do this, or is it like asking too much?

for ... In the ...: If something: #Loop i

In a typical case, when you have more than one level of looping and break your (Because you want to continue one of the upper extremities, not right above the current one), you can do one of the following

To avoid a function, Want to refine the loops

  def internal (): For Jammu: For: In: ... if something: I return in ...: Internal ()  

The disadvantage is that You can make that new function some variable, which was already in the area, you can either just pass them as parameters, make them an example variable on the object (can only create a new object for this function, if This is understandable), or global variable, singleton, whatever (ehm, emm)

Or can you define internal as a nested function and just capture it which it needs (can be slow?)

  for me ... ... def internal (): for in j ...: for in: ... if something: Return Internal ()  

Use exceptions

Philosophically, this is the same, to make exceptions, programmed through structured programming building blocks (if, for, while) Flow break.

The advantage is that you do not have to break a piece of code in many parts. It is good if it is some kind of calculation that you are designing while writing in Python. Presenting these times at the starting point can cause you to slow down.

The worst thing with this approach is that interpreter / compiler writers usually have assumed that exceptions are exceptions and accordingly they are favorable for them.

  Continue the class (exception): pass_i = continueI () for me in ...: try: in j for ...: to k in ...: if Some continue to continue without continuing to continue: ii: Continue:  

Create a special exception class for this, so that you can not accidentally silence any other exception.

Something else completely

I'm sure that still other solution


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -