Skip to content

Instantly share code, notes, and snippets.

@sincerefly
Created July 28, 2017 02:43
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 sincerefly/4fa11ec77302557c2626af6a84bbfe32 to your computer and use it in GitHub Desktop.
Save sincerefly/4fa11ec77302557c2626af6a84bbfe32 to your computer and use it in GitHub Desktop.
用于跨模块共享全局变量的包
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