Jason NovingerM to Python · 3 years agodonno2048/pygoto: Use goto in Pythongithub.comexternal-linkmessage-square4linkfedilinkarrow-up115arrow-down14file-textcross-posted to: programming_horror
arrow-up111arrow-down1external-linkdonno2048/pygoto: Use goto in Pythongithub.comJason NovingerM to Python · 3 years agomessage-square4linkfedilinkfile-textcross-posted to: programming_horror
minus-squarestOneskulllinkfedilinkarrow-up2·edit-23 years agoi’ve found a good alternative is returning functions eg. you have a function like this: def cycle(func): while True: func=func() then you start with cycle(main) def main(): return intro if __name__ == '__main__: cycle(main) and then main returns the next function, and following functions return functions… def intro(): if thisthing: return thisfunc if thatthing: return thatfunc return is being used like goto
minus-squareShayan Salehe@techhub.sociallinkfedilinkarrow-up2·3 years ago@stOneskull @xurxia man it’s really cool
minus-squarestOneskulllinkfedilinkarrow-up3·3 years agoyou can see how i use it here: godschat read from the bottom up
i’ve found a good alternative is returning functions
eg. you have a function like this:
def cycle(func): while True: func=func()then you start with cycle(main)
def main(): return introif __name__ == '__main__: cycle(main)and then main returns the next function, and following functions return functions…
def intro(): if thisthing: return thisfunc if thatthing: return thatfuncreturn is being used like goto
@stOneskull @xurxia man it’s really cool
you can see how i use it here: godschat
read from the bottom up