Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jBenes
jBenes / singleton.py
Last active August 29, 2015 14:27 — forked from 1st/singleton.py
Singleton implantation on Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Singleton(type):
def __call__(self, *args, **kwargs):
if 'instance' not in self.__dict__:
self.instance = super(Singleton, self).__call__(*args, **kwargs)
return self.instance