Skip to content

Instantly share code, notes, and snippets.

@toloco
Created September 17, 2013 14:34
Show Gist options
  • Save toloco/6595168 to your computer and use it in GitHub Desktop.
Save toloco/6595168 to your computer and use it in GitHub Desktop.
'''
Borg kind of singleton
Supraclass for add monostate (all objects share state) properties a class
'''
class BorgObj(object):
_shared_state = {}
def __new__(cls, *a, **k):
obj = super(BorgObj, cls).__new__(cls, *a, **k)
obj.__dict__ = cls._shared_state
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment