is there ‘goto’ module in python ?
so that we can jump several lines using goto/label as follows
goto label
…
…
…
…
label:
…
…
…
is there ‘goto’ module in python ?
so that we can jump several lines using goto/label as follows
goto label
…
…
…
…
label:
…
…
…
There’s a goto library but it’s not part of the standard library and it’s not available on CG.
This library was created as a joke but it seems like few people actually use it.
More information here:
But seriously, I doubt it’s that usefull, the classical use of a goto is to break a deep nested loop, and it can be done easily by just putting the nested loops in a function a calling return to break it all.
Thanks for your reply
And to break deep loops, we can also use try/except as follows
try:
____for … :
________for … :
____________for … :
________________for … :
____________________for … :
________________________for … :
____________________________if condition :
________________________________raise Exception
except :
____pass
this is not real exception, just to break loops