python Singleton


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.