Python goto | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Python goto

how to use goto in python? (sorry for bad english im from poland)

17th Jul 2017, 1:49 PM
Temmie!
Temmie! - avatar
5 Answers
+ 6
I just imagine that any thing I could think of is already been implemented in Python :D
17th Jul 2017, 8:56 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
There is no 'goto' in Python... and anyway, use of 'goto' is considerated as bad practice (even if in low level programming it's an essential function ;P) for high leveled languages. However, someone had wrote a library as a joke, but you're not supposed to really use it ^^ You can download it here: http://entrian.com/goto/download.html And use as: from goto import goto, label   label .start   print "It's not good..."   for i in range(1, 4): print i if i == 2: try: output = message # first run time, this will produce error that we catch below except NameError: print "Going back to retry with an declared and variable." message = "Hello" goto .start   print(output)
17th Jul 2017, 2:06 PM
visph
visph - avatar
+ 4
@visph ^.^ Is there a DIM or GOSUB, as well? :D
17th Jul 2017, 7:50 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
@Kuba: I don't know ^^ ... but you are much experimented than me about Python, and I have no doubt that you could do same kind of google search than me ;P (the fact is, I'm very new to Python, and this force me to verify some fact before answering, so discovering such freaky things)
17th Jul 2017, 8:14 PM
visph
visph - avatar
+ 3
You might enjoy this thread ("I must use goto"..."you may have the only valid use case..."): https://stackoverflow.com/questions/6959360/goto-in-JUMP_LINK__&&__python__&&__JUMP_LINK Because also... 1. The decorator method (far faster) 2. The exception branch method (Python does this to jump out of iterators) 3. The perspective: "....makes state machines faster... ['goto' is like dynamite, for experts a way to remove major obstacles]" ...+ There's always this if you want to go for the jugular :) from goto import comefrom comefrom .repeat s = int(input("Type a number, I'll square it")) print(s**2) label .repeat
7th Aug 2017, 12:57 AM
Kirk Schafer
Kirk Schafer - avatar