Jason NovingerM to Python · 1 year agodonno2048/pygoto: Use goto in Pythongithub.comexternal-linkmessage-square4fedilinkarrow-up115arrow-down14file-text
arrow-up111arrow-down1external-linkdonno2048/pygoto: Use goto in Pythongithub.comJason NovingerM to Python · 1 year agomessage-square4fedilinkfile-text
minus-squarestOneskulllinkfedilinkarrow-up2·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-squarestOneskulllinkfedilinkarrow-up3·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