Skip to content

Instantly share code, notes, and snippets.

@douglarek
Created November 26, 2013 15:29
Show Gist options
  • Save douglarek/7660393 to your computer and use it in GitHub Desktop.
Save douglarek/7660393 to your computer and use it in GitHub Desktop.
class Foo(object):
_instance = None
def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super(Foo, cls).__new__(cls, *args, **kwargs)
return cls._instance
class Brog(object):
__shared_state = {}
def __init__(self):
self.__dict__ = self.__shared_state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment