Guest User

Untitled

a guest
May 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. class Singleton(object):
  2. def __new__(cls, *p, **k):
  3. if not '_the_instance' in cls.__dict__:
  4. cls._the_instance = object.__new__(cls)
  5. return cls._the_instance
  6.  
  7. class Test(Singleton):
  8. def __init__(self):
  9. pass
  10.  
  11. assert Test() is Test()
Add Comment
Please, Sign In to add comment