10 lines
217B

  1. def singleton(cls):
  2. instances = {}
  3. def get_instance(*args, **kwargs):
  4. if cls not in instances:
  5. instances[cls] = cls(*args, **kwargs)
  6. return instances[cls]
  7. return get_instance