Since there is no goto operator in Python, what technique can be used instead?
Condition If it is true, go to thread 1, if is false, go to thread 2 In thread we do something small and after that we go to thread 2 where all other actions take place.
Since there is no goto operator in Python, what technique can be used instead?
Constructing your code logically and semantically.
if condition:
perform_some_action()
perform_other_actions()
def thread_1():
# Do thread_1 type stuff here.
def thread_2():
# Do thread_2 type stuff here.
if condition:
thread_1()
# If condition was false, just run thread_2().
# If it was true then thread_1() will return to this point.
thread_2()
edit: I'm assuming that by "thread" you mean a piece of code (otherwise known as a subroutine or a function). If you're talking about threads as in parallel execution then you'll need more detail in the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With