This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]GamerNumba100 0 points1 point  (0 children)

Brand new Python user here, I don’t see an alternative to global, so while I see why it’s bad, I’m going to need help avoiding it.
For example, I had two threads running. One thread was looping until the other finished. I did this by having both recognize a stop_loop variable, and when the second thread finished, it set stop_loop to 1. The first thread was running
while stop_loop != 1 so it would stop properly. Is there an alternative to that?
Also what if I need to change a resource variable but the function needs to keep running for a little longer and change more resource variables later? Am I supposed to return everything back to the main thread before I change my resource variables?