Created
July 28, 2017 02:43
-
-
Save sincerefly/4fa11ec77302557c2626af6a84bbfe32 to your computer and use it in GitHub Desktop.
用于跨模块共享全局变量的包
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
import sys | |
class global_flag(object): | |
def __init__(self): | |
self.flag_value = False | |
def get(self): | |
return self.flag_value | |
def change(self): | |
self.flag_value = not self.flag_value | |
sys.modules[__name__] = global_flag() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment