Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
metaclass=Singleton solution in Clear category for Capital City by flpo
class Singleton(type):
instance = None
def __call__(cls, *args, **kwargs):
if cls.instance is None:
cls.instance = super(Singleton, cls).__call__(*args, **kwargs)
return cls.instance
class Capital(metaclass=Singleton):
def __init__(self, name):
self._name = name
def name(self):
return self._name
June 11, 2018
Comments: