Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Singleton(object):
- def __new__(cls, *p, **k):
- if not '_the_instance' in cls.__dict__:
- cls._the_instance = object.__new__(cls)
- return cls._the_instance
- class Test(Singleton):
- def __init__(self):
- pass
- assert Test() is Test()
Add Comment
Please, Sign In to add comment