Jason Novinger@programming.devM to Python@programming.dev · 1 year agodonno2048/pygoto: Use goto in Pythongithub.comexternal-linkmessage-square11fedilinkarrow-up113arrow-down14file-textcross-posted to: programming_horror@programming.dev
arrow-up19arrow-down1external-linkdonno2048/pygoto: Use goto in Pythongithub.comJason Novinger@programming.devM to Python@programming.dev · 1 year agomessage-square11fedilinkfile-textcross-posted to: programming_horror@programming.dev
minus-squarestOneskull@programming.devlinkfedilinkarrow-up1·edit-21 year 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·1 year ago@stOneskull @xurxia man it’s really cool
minus-squarestOneskull@programming.devlinkfedilinkarrow-up2·1 year 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 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
@stOneskull @xurxia man it’s really cool
you can see how i use it here: godschat
read from the bottom up