Created
April 4, 2017 23:11
-
-
Save nuttycom/cb21ad5f89e3238a1298e3f3576aaa50 to your computer and use it in GitHub Desktop.
Python scoping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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