Created
July 23, 2009 11:45
-
-
Save wrboyce/152794 to your computer and use it in GitHub Desktop.
Borg Design Pattern for a Shared State across Instances of a Class
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
class Borg(object): | |
""" Borg Design Pattern for a Shared State across Instances of a Class. """ | |
__hivemind = {} | |
def __new__(cls, *args, **kwargs): | |
self = super(cls.__class__, cls).__new__(cls, *args, **kwargs) | |
self.__dict__ = cls.__hivemind[cls.__name__] = {} | |
return self |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment