def singleton(klass):
instances = {}<EOL>def getinstance(*args, **kwargs):<EOL><INDENT>if klass not in instances:<EOL><INDENT>instances[klass] = klass(*args, **kwargs)<EOL><DEDENT>return instances[klass]<EOL><DEDENT>return wraps(klass)(getinstance)<EOL>
Create singleton from class