1

There is no goto in python, but what is the reason behind the unavailability of goto in python 2.X?

Please tell me.

Junuxx
  • 14,011
  • 5
  • 41
  • 71
neotam
  • 2,611
  • 1
  • 31
  • 53

4 Answers4

13

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.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Yes, between exceptions AND loops, there is no need, see a quick tutorial on looping: http://www.dreamsyssoft.com/python-scripting-tutorial/loops-tutorial.php – Rocky Pulley Jan 09 '13 at 14:30
2

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.

Why is goto poor practise? and

GOTO still considered harmful?

Community
  • 1
  • 1
Grijesh Chauhan
  • 57,103
  • 20
  • 141
  • 208
1

Python saw the error in their ways, and added a goto!

Just Kidding - please don't use in real code

It was released as an April Fools Joke.

Gerrat
  • 28,863
  • 9
  • 73
  • 101