0
donno2048/pygoto: Use goto in Python
(github.com)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
Hi,
I have used goto instruction a lot when I started to program in Basic ( an Amstrad CPC 🥹). In this context goto had logic. But in modern languages like python I think it is a very bad idea:
Regards
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