Jason Novinger@programming.devM to Python@programming.dev · 1 year agodonno2048/pygoto: Use goto in Pythongithub.comexternal-linkmessage-square12fedilinkarrow-up113arrow-down14file-textcross-posted to: [email protected]
arrow-up19arrow-down1external-linkdonno2048/pygoto: Use goto in Pythongithub.comJason Novinger@programming.devM to Python@programming.dev · 1 year agomessage-square12fedilinkfile-textcross-posted to: [email protected]
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