File size: 215 Bytes
0dffae9
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8

def singleton(cls):
    instances = {}
    def get_instance(*args, **kwargs):
        if cls not in instances:
            instances[cls] = cls(*args, **kwargs)
        return instances[cls]
    return get_instance