You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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