Jason Novinger@programming.devM to Python@programming.dev · 3 years agodonno2048/pygoto: Use goto in Pythongithub.comexternal-linkmessage-square9linkfedilinkarrow-up18arrow-down13file-text
arrow-up15arrow-down1external-linkdonno2048/pygoto: Use goto in Pythongithub.comJason Novinger@programming.devM to Python@programming.dev · 3 years agomessage-square9linkfedilinkfile-text
minus-squarestOneskull@programming.devlinkfedilinkarrow-up1·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
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