Skip to content

Instantly share code, notes, and snippets.

@nuttycom
Created April 4, 2017 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuttycom/cb21ad5f89e3238a1298e3f3576aaa50 to your computer and use it in GitHub Desktop.
Save nuttycom/cb21ad5f89e3238a1298e3f3576aaa50 to your computer and use it in GitHub Desktop.
Python scoping
def foo():
done = [False];
def handle_sigint(signal, frame):
done[0] = True;
print("SIGINT received; stopping...")
signal.signal(signal.SIGINT, handle_sigint)
while not done[0]:
print("not done")
def foo():
done = False;
def handle_sigint(signal, frame):
done = True;
print("SIGINT received; stopping...")
signal.signal(signal.SIGINT, handle_sigint)
while not done:
print("not done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment