3 class _Singleton(type):
4 """ A metaclass that creates a Singleton base class when called. """
7 def __call__(cls, *args, **kwargs):
8 if cls not in cls._instances:
9 cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
10 return cls._instances[cls]
13 class Singleton(_Singleton('SingletonMeta', (object,), {})):
19 from urlparse import urlparse
21 from urllib.parse import urlparse