There is no goto in python, but what is the reason behind the unavailability of goto in python 2.X?
Please tell me.
From the Python FAQ:
Why is there no goto?
You can use exceptions to provide a “structured goto” that even works across function calls. Many feel that exceptions can conveniently emulate all reasonable uses of the “go” or “goto” constructs of C, Fortran, and other languages.
In other words: there is no need for goto
when you have exception handling.
You can do every thing using if
, else
, while
and for
constructs, adding goto
means unstructured programming. goto
don't add any extra power in language, its just an unconditional loop.
Even in languages like FORTRAN, where there is still a GOTO, it's not usually recommended that you use it: